cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Action with Parameter: How can I restrict the choice to a single user?

heike
Champ on-the-rise
Champ on-the-rise

I added a custom action to set the value of a custom property "contact person". Now I need a form control that let's the user choose an existing user. I tried authority.ftl, but that way it is possible to select groups as well as single users.

This is part of my share-config-custom.xml:

<!-- Actions -->
<config evaluator="string-compare" condition="DocLibActions">
  <actions>
    <action id="assign-contact-person" type="javascript" label="actions.assign-cp" icon="assign-cp">
      <param name="function">onActionFormDialog</param>
      <param name="itemKind">action</param>
      <param name="itemId">assign-cp</param>
      <param name="mode">create</param>
      <param name="destination">{node.nodeRef}</param>
      <param name="successMessage">message.assign-cp.success</param>
      <param name="failureMessage">message.assign-cp.failure</param>
      <permissions>
        <permission allow="true">Write</permission>
      </permissions>
    </action>
  </actions>
  <actionGroups>
    <actionGroup id="document-browse">
      <action index="500" id="assign-contact-person" />
    </actionGroup>
    <actionGroup id="document-details">
      <action index="500" id="assign-contact-person" />
    </actionGroup>
  </actionGroups>
</config>

<config evaluator="string-compare" condition="assign-cp">
  <forms>
    <form>
      <field-visibility>
        <show id="contactPerson"/>
      </field-visibility>
      <appearance>
        <field id="contactPerson" label="Contact Person">
          <control template="/org/alfresco/components/form/controls/authority.ftl"/>
        </field>
      </appearance>
    </form>
  </forms>
</config>


I would also follow a different approach, allowing end users to edit the custom property via "Edit Properties" - then I would need a custom constraint that makes sure that only existing user names can be selected. Is there any way to achieve this?

1 REPLY 1

douglascrp
World-Class Innovator
World-Class Innovator

Hello.

Please, check this out GitHub - douglascrp/alfresco-group-member-control: Custom form control that allows you to select use... 

I believe you can try to use the custom form control provided by this project as a starting point to you to customize the control to show only users.