how to add custom association in Workflow in SkriptTaskListener

cancel
Showing results for 
Search instead for 
Did you mean: 
beanywhere
Member II

how to add custom association in Workflow in SkriptTaskListener

Hi all,
I have an association in my custom workflow model.

------------------------------------------------------------

<aspect name="ddwf:customData">
<properties>
  <property name="ddwf:customText">
   <type>d:text</type>
   <mandatory>false</mandatory>
  </property>
</properties>

<associations>
  <association name="ddwf:customAssoc">
   <source>
    <mandatory>false</mandatory>
    <many>false</many>
   </source>
   <target>
    <class>ddwf:customType</class>
    <mandatory>false</mandatory>
    <many>true</many>
   </target>
  </association>
</associations>
</aspect>

<type name="ddwf:customType">
<properties>
  <property name="ddwf:customTypeName">
   <type>d:text</type>
  </property>
  <property name="ddwf:customTypeMessage">
   <type>d:text</type>
  </property>
</properties>
</type>

------------------------------------------------------------

I know how to set Properties inside a ScriptTaskListener:


execution.setVariable('ddwf:customText', "Here is the custom Text");

I know how to generate the type:


var newCT = companyHome.createNode("Test","ddwf:customType");
newCT.properties["ddwf:customTypeName"] = "Custom Name";
newCT.properties["ddwf:customTypeMessage"] = "Custom Message";
newCT.save();

But I cannot associate the new Node, because execution.getVariable('ddwf:customAssoc') is always undefined.

How can I add newCT to my customModel ?


execution.setVariable('ddwf:customAssoc', newCT)

does not work.

Is it possible ? I haven't found an example

Thank you

2 Replies
afaust
Master

Re: how to add custom association in Workflow in SkriptTaskListener

Your variable name should be "ddwf_customAssoc". All variable names (for properties or associations) have to use the _ instead of : (only the first : is replaced), because this is how Alfresco maps those into/from workflow data.

Also, you technically need to have an ActivitiScriptNode as a value, whereas you currently have a simple ScriptNode. Unfortunately, there is no way from JavaScript to create an ActivitiScriptNode, which makes it a bit difficult to handle. You'd have to create a script API root scope object written in Java to handle that for you.

beanywhere
Member II

Re: how to add custom association in Workflow in SkriptTaskListener

Hi axel,

Sorry "ddwf:customAssoc" was a Typo. I did try it with "ddwf_customAssoc". So I will try a Java-backed TaskListener instead of a Javascript-backed one. Thank you very much.