AnsweredAssumed Answered

Add New Behaviour

Question asked by ghernando on Oct 17, 2008
I'm trying to add a simple behaviour using Javascript that updates a property on a file/document at the time of checkin based on some other mandatory properties that have been specified.

I wrote a Javascript and have tried to reference it from the model-context file as follows:

    <bean id="onContentUpdateSetContent" 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">


After I configure the bean as shown, I see an error during the checkin wizard process immediately after uploading the file.
So it seems to know that I've configured something.
It never gets to the "Modify Content Properties" page where the properties are entered by the user.

I see an error like:

Please correct the errors below then click OK.

    * A system error happened during the operation: Failed to set content property on stream closure: node: workspace://SpacesStore/62d3d04a-9c53-11dd-ad30-b9444f2fde8e property: {}content writer: ContentAccessor[ contentUrl=store://2008/10/17/6/56/62fefefd-9c53-11dd-ad30-b9444f2fde8e.bin, mimetype=application/vnd.excel, size=90112, encoding=UTF-8, locale=en_US]


Is onContentUpdate the wrong behaviour to be trying to reference?  I also tried onCreateNode with a similar error.

Another question is that I try to use the JS Alfresco document object in the Javascript to be run.  Will that be available to me on scripts associated with these Behaviors?