Colon is not replaced by underscore in name of the property when passed to end-event script

StackOverflow https://stackoverflow.com/questions/21991236

  •  15-10-2022
  •  | 
  •  

Question

I am trying to define workflow in Alfresco 4.2. I have a type defined as follows:

    <type name="abc:start">
        <parent>bpm:startTask</parent>
        <associations>
            <association name="abc:client">
                <source>
                    <mandatory>true</mandatory>
                    <many>true</many>
                </source>
                <target>
                    <class>cm:person</class>
                    <mandatory>false</mandatory>
                    <many>false</many>
                </target>
            </association>
        </associations>
    </type>

This type is used start event of an workflow:

<config evaluator="string-compare" condition="activiti$sa05">
    <forms>
        <form>
            <field-visibility>
                <show id="packageItems" />
                <show id="abc:client"/>
            </field-visibility>
            <appearance>
                <set id="items" appearance="title" />
                <set id="info" appearance="title" />

                <field id="packageItems" set="items" />
                <field id="abc:client" set="info" />
            </appearance>
        </form>
    </forms>

In the event I have a very simple script (started at end of event), which uses this association:

logger.log("Starting workflow for: " + abc_client);
execution.setVariable("abc:client", abc_client);

When I start workflow for the first time, everything is ok. When I start it for the second time, I get the following error:

Failed to execute supplied script: 01240010 ReferenceError: "abc_client" is not defined. (AlfrescoJS#2)

I set a breakpoint in RhinoScriptProcessor and I was able to see that "abc:client" gets passed to script, rather then "abc_client". Why is it so? Why this isn't deterministic?

Was it helpful?

Solution

It turns out that the following line was problematic:

execution.setVariable("abc:client", abc_client);

Alfresco keeps an internal cache of two-way-mapping: qualified name <-> variable name. On first execution of workflow {abc namespace}client is mapped to abc_client. But then the above line gets executed and now {abc namespace}client is mapped to abc:client. As the result, on the next execution of the workflow abc:client is passed, rather then abc_client.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top