01-26-2021 04:48 AM
Hello. I need to change owner property of document, for this i use next code
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE); nodeService.setProperty(nodeRef, ContentModel.PROP_CREATOR, NEW_DOCUMENT_OWNER); nodeService.setProperty(nodeRef, ContentModel.PROP_MODIFIER, NEW_DOCUMENT_OWNER);
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
in service task of workflow in class ChangeDocumentsOwner implements JavaDelegate.
I call this file in file.bpmn20.xml
<serviceTask id="servicetask1" name="Service Task" activiti:async="true" activiti:class="org.alfresco.repo.workflow.activiti.script.ChangeDocumentsOwner"></serviceTask>
But i can't get behaviourFilter instance. nodeService instance i got from the next code
Map<Object, Object> registeredBeans = Context.getProcessEngineConfiguration().getBeans();
ServiceRegistry registry = (ServiceRegistry)registeredBeans.get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
NodeService nodeService = registry.getNodeService();
I tried to register bean ChangeDocumentsOwner
<bean id="ChangeDocumentsOwner" class="org.alfresco.repo.workflow.activiti.script.ChangeDocumentsOwner" parent="webscript"> <property name="nodeService" ref="NodeService" /> <property name="behaviourFilter" ref="policyBehaviourFilter" /> </bean>
but properties was null. Can i get behaviourFilter instance? Or, maybe there are other solutions to my problem?
01-26-2021 07:11 AM
Problem was in bean and call inside service task.
Correct code
<serviceTask id="servicetask1" name="Service Task" activiti:async="true" activiti:delegateExpression="${ChangeDocumentsOwner}"></serviceTask>and
<bean id="AbstractChangeDocumentsOwner" parent="baseJavaDelegate" abstract="true" depends-on="activitiBeanRegistry" /> <bean id="ChangeDocumentsOwner" parent="AbstractChangeDocumentsOwner" class="org.alfresco.repo.workflow.activiti.script.ChangeDocumentsOwner"> <property name="nodeService" ref="NodeService" /> <property name="behaviourFilter" ref="policyBhaviourFilter" /> </bean>
01-26-2021 07:11 AM
Problem was in bean and call inside service task.
Correct code
<serviceTask id="servicetask1" name="Service Task" activiti:async="true" activiti:delegateExpression="${ChangeDocumentsOwner}"></serviceTask>and
<bean id="AbstractChangeDocumentsOwner" parent="baseJavaDelegate" abstract="true" depends-on="activitiBeanRegistry" /> <bean id="ChangeDocumentsOwner" parent="AbstractChangeDocumentsOwner" class="org.alfresco.repo.workflow.activiti.script.ChangeDocumentsOwner"> <property name="nodeService" ref="NodeService" /> <property name="behaviourFilter" ref="policyBhaviourFilter" /> </bean>
Explore our Alfresco products with the links below. Use labels to filter content by product module.