AnsweredAssumed Answered

Simple script called by behavior-context

Question asked by cristian on Aug 26, 2010
Latest reply on Aug 26, 2010 by cristian
I've got this script (onUpdateOrder.js) that works right in a rule's "Execute Script" action.
The goal is to update a custom cm:folder property with the sum of its children property, when a custom type ("my:item") is updated in the context folder.
var childrenList = space.children;
if (childrenList)
    for (var i = 0; i < childrenList.length; i++)
        item = childrenList[i];
        itemPrice =["my:itemPrice"];
        total += itemPrice;
    }["my:itemsSum"] = total;;
.. I tried to trigger this script in a behavior-context.xml:
    <bean id="onUpdateOrderNode" class="org.alfresco.repo.policy.registration.ClassPolicyRegistration" parent="policyRegistration">
        <property name="policyName">
        <property name="className">
        <property name="behaviour">
           <bean class="org.alfresco.repo.jscript.ScriptBehaviour" parent="scriptBehaviour">
                        <property name="location">
                                <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">
..but "space" is undefined. How to get the correct context in this environment??