As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<aspect name="gs:publishable"> <title>Metadati sulle informazioni di pubblicazione</title> <properties> <property name="gs:ToBePublished"> <type>d:boolean</type> <mandatory>true</mandatory> <index enabled="true"> <atomic>true</atomic> <stored>true</stored> <tokenised>false</tokenised> </index> </property> <property name="gs:PublishDate"> <type>d:date</type> <index enabled="true"> <atomic>true</atomic> <stored>false</stored> <tokenised>both</tokenised> </index> </property> <property name="gs:UnpublishDate"> <type>d:date</type> <index enabled="true"> <atomic>true</atomic> <stored>false</stored> <tokenised>both</tokenised> </index> </property> </properties> </aspect>
<bean id="onChangePublishDate" class="org.alfresco.repo.policy.registration.ClassPolicyRegistration" parent="policyRegistration"> <property name="policyName"> <value>{http://www.alfresco.org}onUpdateProperties</value> <!– this is the method that triggers my behaviour… is it correct? –> </property> <property name="className"> <value>????????</value> <!– What should I put here? –> </property> <property name="behaviour"> <bean class="org.alfresco.repo.jscript.ScriptBehaviour" parent="scriptBehaviour"> <property name="location"> <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation"> <constructorarg> <value>alfresco/extension/scripts/myscript.js</value> </constructorarg> </bean> </property> </bean> </property> </bean>
<import resource="classpath:alfresco/extension/scripts/myUpgradeScriptFields.js"> var scriptFailed = false; // Have a look at the behaviour object that should have been passed if (behaviour == null) { logger.log("The behaviour object has not been set."); scriptFailed = true; } // Check the name of the behaviour…. in my case is onUpdateProperties??? if (behaviour.name == null && behaviour.name != "onUpdateProperties") { logger.log("The behaviour name has not been set correctly."); scriptFailed = true; } else { logger.log("Behaviour name: " + behaviour.name); } // in my case I need to check the arguments?? if (behaviour.args == null) { logger.log("The args have not been set."); scriptFailed = true; } else { logger.log("Calling update fields"); updateFields(myArg); //method implemented in the myUpgradeScriptFields.js } else { logger.log("The number of arguments is incorrect."); scriptFailed = true; } }
<bean id="onUpdateHrDoc" class="org.alfresco.repo.policy.registration.ClassPolicyRegistration" parent="policyRegistration"> <property name="policyName"> <value>{http://www.alfresco.org}onUpdateNode</value> </property> <property name="className"> <value>{http://www.someco.com/model/content/1.0}hrDoc</value> </property> <property name="behaviour"> <bean class="org.alfresco.repo.jscript.ScriptBehaviour" parent="scriptBehaviour"> <property name="location"> <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation"> <constructor-arg> <value>alfresco/extension/scripts/onUpdateNode.js</value> </constructor-arg> </bean> </property> </bean> </property> </bean>
Regarding your JavaScript, it looks like the right approach, although syntactically it may need some help. I think I see a problem with your final if-else block–are there two else's there?
16:36:24,453 DEBUG [org.alfresco.repo.jscript.ScriptLogger] json form submission for item: 16:36:24,453 DEBUG [org.alfresco.repo.jscript.ScriptLogger] kind = node 16:36:24,453 DEBUG [org.alfresco.repo.jscript.ScriptLogger] id = workspace/SpacesStore/b2725bbb-98c4-4bc2-a1b5-bcd247eae99f 16:36:24,484 DEBUG [org.alfresco.repo.jscript.ScriptLogger] org.alfresco.scripts.ScriptException: 05130132 Failed to execute script 'alfresco/extension/scripts/onChangePublishDate.js': null 16:36:24,484 DEBUG [org.alfresco.repo.jscript.ScriptLogger] Returning 500 status code
<bean id="onChangePublishDateNode" class="org.alfresco.repo.policy.registration.ClassPolicyRegistration" parent="policyRegistration"> <property name="policyName"> <value>{http://www.alfresco.org}onUpdateProperties</value> </property> <property name="className"> <value>{http://giunti.noze.it/model/content/1.0}properties</value> </property> <property name="behaviour"> <bean class="org.alfresco.repo.jscript.ScriptBehaviour" parent="scriptBehaviour"> <property name="location"> <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation"> <constructor-arg> <value>alfresco/extension/scripts/onChangePublishDate.js</value> </constructor-arg> </bean> </property> </bean> </property> </bean>
<import resource="classpath:alfresco/extension/script/changeDate.js">
<property name="className"> <value>{http://giunti.noze.it/model/content/1.0}properties</value> </property>
From looking at your spring config, it looks like you've specified your class name as: <property name="className"> <value>{http://giunti.noze.it/model/content/1.0}properties</value> </property>I was expecting that to be a type or an aspect. Do you have a type or an aspect named "{http://giunti.noze.it/model/content/1.0}properties"?Jeff
<bean id="giuntiDictionaryModelBootstrap.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap"> <property name="models"> <list> <value>alfresco/extension/giunti-model.xml</value> </list> </property> </bean>
<namespaces> <namespace uri="http://giunti.noze.it/model/content/1.0" prefix="gs" /> </namespaces>
<aspect name="gs:properties"> <title>…. </title> <properties>… … </properties>
Yes, that looks good, but I would strongly recommend changing the name of that aspect to something a little more descriptive and unique so that when you add other aspects to your model you'll be able to tell the difference between the two.Jeff