How to set document aspect property cm:person

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set document aspect property cm:person

pnature
Established Member
0 0 1,169

I am using Alfresco community version: 5.2.0 (r135134-b14)

If you have document with aspect containing cmSmiley Tongueerson property.

   <aspects>
      <aspect name="ad:approveDocument">
            <title>Approver for Approve document</title>
            <associations>
              <association name="ad:approver">
                <title>Assignee</title>
                <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
                </source>
                <target>
                  <class>cmSmiley Tongueerson</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
                </target>
              </association>

                                 ...

When you start workflow on document with this aspect I can read property ad:approver

When you want to set property ad:approver you have to

private static final String adNamespace = "http://www.namespace.com/model/approveDocument";

ServiceRegistry serviceRegistry = (ServiceRegistry)registeredBeans.get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);

NodeRef docref= serviceRegistry.getNodeService().getChildAssocs(packagenode).get(0).getChildRef();

String username = "myUser";

NodeRef person = personService.getPerson(username);

nodeService.setAssociations(docref, QName.createQName(adNamespace, "approver"), Arrays.asList(person));