cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Alfresco ScripNode to ActivitiScriptNode

erny18031
Champ in-the-making
Champ in-the-making
Hi.

In a Alfresco 4.2.c workflow, I have a task model like this:
<blockcode>

<type "my:tasktype">

           <property name="my:folder">
                <title>Folder</title>
                <type>d:noderef</type>
            </property>

</blockcode>

and I use a ScriptExecutionListener like this:
<javascript>

var folder = companyhome.createFolder(name);
execution.setVariable("my_folder") = folder.nodeRef;

</javascript>

but I receive an exception with message:
<blockcode>

org.activiti.engine.ActivitiException: Passed value is not an instance of ActivitiScriptNode, cannot set variable value.

</blockcode>

Is it possible to convert Alfresco ScriptNode type to ActivitiScriptNode from within JavaScript? How?

I've googled a lot and read Alfresco source code, but still haven't found a way to do it.

Thanks
Regards.
Erny
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
I guess you can try to call the constructor of public ActivitiScriptNode(NodeRef nodeRef, ServiceRegistry services), passing in the raw nodeRef and service-registry.

If registry is unavailable, you can always pass in null, as long as you don't immediately (in the same script) perform actions on or access properties of the newly created ActivitiScriptNode, that's fine. The next time the ScriptNode is used, it will be fully usable with a valid service-registry, as this is added when fetched from the engine again.

If this doesn't work, it's always possible to add a custom variableType (or override the ScriptNodeVariableType) to be more flexible on input, but always read variables as ActivitiScriptNodes… But that's not trivial, so I hope the first suggestion works Smiley Wink

erny18031
Champ in-the-making
Champ in-the-making
Hi.

I'll try this and give feedback. I didn't know that it's possible to call the constructor with service-registry = null.
Thanks a lot.
Erny