How to assign task to the group from a variable in Workflow

cancel
Showing results for 
Search instead for 
Did you mean: 
Rahul_Nathwani
Active Member

How to assign task to the group from a variable in Workflow

Jump to solution

This is one workflow in which I want to assign the task to the group depending on the condition, So in the initial check I am getting that condition true or false based on that I have also assigned group names to one variable "wf142_grouprevisor" but now I want to pass that variable name in the activiti:candidateGroups="${wf142_grouprevisor.properties.Name}" .   I have tried the below code but it is not working means it is not taking the group name from the variable.. Can anyone help me in this issue.

 

Thanks in Advance..

 

<serviceTask id="workflow142InitialCheck" name="Payroll Check"
activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
<extensionElements>
<activiti:field name="runAs">
<activiti:string>
<![CDATA[admin]]>
</activiti:string>
</activiti:field>
<activiti:field name="script">
<activiti:string>
logger.error("Payroll Task starts");
var destinationFolder = companyhome.childByNamePath("Staging");
var docs = bpm_package.children;
var docType = docs[0].properties["hr:documentType"];
var keyNo = docs[0].properties["hr:keyNumber"];
var process = "";
var docTypeStr = "";
var checkSecured = "";

var nodes = search.luceneSearch("@\\{http\\://www.bpost.be/model/hr/1.0\\}DocumentTypesDataList @hr\\:dldocType:"+docType+"\*");
logger.error("--------Length of nodes is-------------"+nodes.length);
if(nodes.length > 0){

logger.error("------------Node is-------------"+nodes[0].id);

var dataLists = search.findNode("workspace://SpacesStore/"+nodes[0].id);
var dataListItemProps = dataLists.getProperties(); //Read all the properties of the current datalistitem

docTypeStr = dataListItemProps["hr:dldocType"]
logger.log("-----docTypeStr-------"+docTypeStr);

process = dataListItemProps["hr:dlprocess"];
logger.log("+++++Process+++++"+process);

checkSecured = dataListItemProps["hr:dlsecured"];
logger.error("-------CHECK SECURED---------"+checkSecured);
}

if(checkSecured == true){
execution.setVariable('wf142_grouprevisor',"GROUP_GU_CMS_HR_PAYROLLSECWF_TEAM");
logger.error("--------wf142_grouprevisor---------------"+wf142_grouprevisor);
}else{
execution.setVariable('wf142_grouprevisor',"GROUP_GU_CMS_HR_NONSECWF_TEAM");
logger.error("--------wf142_grouprevisor---------------"+wf142_grouprevisor);
}

if(!docType || !keyNo){

execution.setVariable('wf142_initialFlag',true);
docs[0].move(destinationFolder);
logger.log("Here it is....")
}else{
execution.setVariable('wf142_initialFlag',false);
}
logger.error("Payroll Task ends");
</activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>

<exclusiveGateway id="exclusiveGateway" name="Exclusive Gateway" />

<sequenceFlow id="flow11" targetRef="workflow142Review"
sourceRef="exclusiveGateway">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf142_initialFlag == false}]]></conditionExpression>
</sequenceFlow>

<sequenceFlow id="flow12" targetRef="endevent" sourceRef="exclusiveGateway">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf142_initialFlag == true}]]></conditionExpression>
</sequenceFlow>

<userTask id="workflow142Review" name="Payroll"
activiti:candidateGroups="${wf142_grouprevisor.properties.Name}" activiti:formKey="wf142:workflow142Review">
<extensionElements>
<activiti:taskListener event="create"
class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
<![CDATA[

1 Solution

Accepted Solutions
abbask01
Senior Member

Re: How to assign task to the group from a variable in Workflow

Jump to solution

you'll have to provide the ID of the group which your are assigning the task to in your varaible wf142_grouprevisor then simple pass the variable as expression ${wf142_grouprevisor}. Activiti cannot resolve groups based on names. FYI ${wf142_grouprevisor.properties.Name} << this type of expression can only be used if wf142_grouprevisor is an instance of ScriptNode

Regards,
Abbas

View solution in original post

3 Replies
abbask01
Senior Member

Re: How to assign task to the group from a variable in Workflow

Jump to solution

you'll have to provide the ID of the group which your are assigning the task to in your varaible wf142_grouprevisor then simple pass the variable as expression ${wf142_grouprevisor}. Activiti cannot resolve groups based on names. FYI ${wf142_grouprevisor.properties.Name} << this type of expression can only be used if wf142_grouprevisor is an instance of ScriptNode

Regards,
Abbas
Rahul_Nathwani
Active Member

Re: How to assign task to the group from a variable in Workflow

Jump to solution

Hi abbask01,

Thanks for the solution. It helped to solve my issue. Now the workflow is taking the group name as per the condition.

Once Again Thanks.

EddieMay
Alfresco Employee

Re: How to assign task to the group from a variable in Workflow

Jump to solution

@Rahul_Nathwani,

Thanks for the feedback and accepting the solution - helpful to other users. 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!