Hi.
I am new and I am using Alfresco 5.1 community version.
Tell me please simple way to create form with list of users in Alfresco Share.
I have tried customize share-config-custom.xml
Use selectone.ftl with
<field id="xx:approver" label-id="prop.xx_approver" >
<control template="/org/alfresco/components/form/controls/selectone.ftl" >
<control-param name="options">/alfresco/service/api/people</control-param>
</control>
</field>
is not the right way.
I have tried custom ftl but I cannot put user list into options.
How can I read users from Alfresco and put them into options of selectone?
Thanks in advance.
Solved! Go to Solution.
What do you mean by a list of users?
The select one form control is a simple combobox that will show a list of string values, and not complex objects like users. It will not allow you to define an webscript as the data source, as you tried.
How have you defined your custom property?
Is it a d:text property? or is it an association with cmerson objects.
If it is the second, then you have to do nothing, as the forms engine will use the right form control to allow you to search and select users.
What do you mean by a list of users?
The select one form control is a simple combobox that will show a list of string values, and not complex objects like users. It will not allow you to define an webscript as the data source, as you tried.
How have you defined your custom property?
Is it a d:text property? or is it an association with cmerson objects.
If it is the second, then you have to do nothing, as the forms engine will use the right form control to allow you to search and select users.
Thank you for your response.
I have defined my custom properties as d:text for the start.
I want to somehow use selectone as in case bpm:assignee. It is used in New Task process start. I cannot find how to do it.
I have tried use cmerson
<type name="ipp:headTask">
<parent>bpm:activitiOutcomeTask</parent>
<properties>
<property name="ipp:assignee">
<type>cmerson</type>
<mandatory>true</mandatory>
<index enabled="true"/>
</property>
</properties>
<associations/>
<mandatory-aspects/>
</type>
but I get org.alfresco.service.cmr.dictionary.DictionaryException: 05060000 Property type 'cmerson' of property 'ipp:assignee' is not found
Ok, so in this case, what you need is an association, and not a property.
You can see how an association is defined by checking the bpm:assignee definition at community-edition-old/bpmModel.xml at master · Alfresco/community-edition-old · GitHub
As you can see, it is a different kind of configuration, where you have a source (the object you are working on) and the target, in this case, a cmerson object.
If you use that configuration in your content model, share will know what component to use to allow you to select a person.
Yes. I have change it to
<association name="ipp:assignee">
<title>Assignee</title>
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:person</class>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
it works very good. Thank you.
But now I face the problem to get username from ipp:assignee and assign it to next task.
<userTask id="alfrescoUsertask1" name="Task" activiti:assignee="${headUserName}" activiti:formKey="ipp:headTask">
<extensionElements>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[
execution.setVariable('secondAssignee', task.getVariable('ipp_assignee'));]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<userTask id="alfrescoUsertask2" name="Assigned Task" activiti:assignee="${secondAssignee}" activiti:formKey="ipp:headTask">
Now I get this error
### The error may involve org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity.insertHistoricTaskInstance-Inline
### The error occurred while setting parameters
### SQL: insert into ACT_HI_TASKINST ( ID_, PROC_DEF_ID_, PROC_INST_ID_, EXECUTION_ID_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, OWNER_, ASSIGNEE_, START_TIME_, CLAIM_TIME_, END_TIME_, DURATION_, DELETE_REASON_, TASK_DEF_KEY_, FORM_KEY_, PRIORITY_, DUE_DATE_, CATEGORY_, TENANT_ID_ ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
### Cause: org.h2.jdbc.JdbcSQLException: Hodnota je príliš dlhá pre stĺpec "ASSIGNEE_ VARCHAR(255)": "'Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects: [{http://www.alfresco.org/model/content/1.0}ownable... (295)"
Value too long for column "ASSIGNEE_ VARCHAR(255)": "'Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects: [{http://www.alfresco.org/model/content/1.0}ownable... (295)"; SQL statement:
insert into ACT_HI_TASKINST ...
Hello.
Can you try replacing this line
execution.setVariable('secondAssignee', task.getVariable('ipp_assignee'));
with this?
execution.setVariable('secondAssignee', task.getVariable('ipp_assignee').properties["cm:userName"]);
It looks fine. I have made workaround in java.
script:
execution.setVariable('nextAssigneeObject', task.getVariable('ipp_assignee'));
java:
final Map<Object, Object> registeredBeans = Context.getProcessEngineConfiguration().getBeans();
final ServiceRegistry serviceRegistry = (ServiceRegistry)registeredBeans.get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
final NodeService nodeService = serviceRegistry.getNodeService();
ActivitiScriptNode scriptNode = (ActivitiScriptNode) execution.getVariable("nextAssigneeObject");
NodeRef person = scriptNode.getNodeRef();
final Map<QName, Serializable> properties = nodeService.getProperties(person);
String assigneUsername = properties.get(ContentModel.PROP_USERNAME).toString();
execution.setVariable("nextAssignee", assigneUsername);
script:
execution.setVariable('secondAssignee',execution.getVariable('nextAssignee'));
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.