09-11-2017 06:53 AM
I have tree users group and want to assign task to the users group based on complexity value.These are my group users:
1-expert_users
2-senior_users
3-junior_users
1-If complexity value is "High" then the task must be assigned to expert_users group
2-If complexity value is "Medium" then the task must be assigned to senior_users group
3-If complexity value is "Low" then the task must be assigned to junior_users group
I have created task listener as follow:
And I have used expression as follow:
I have set an variable as global scope as follow:
After done above implementation, I am getting below error:
Please let me know what I am doing wrong here.
Thanks
09-14-2017 04:47 AM
After I have modified task listener implementation, the error has gone but dynamic group assignment still not working.
09-27-2017 01:26 AM
This is done by using this following implementation:
03-03-2019 08:45 PM
The GroupService is part of which library?
03-07-2019 01:01 AM
Hi,
Please find the attached app.
You can write your task listener as like below, hope it solves your problem.
package com.activiti.extension.bean;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.impl.util.json.JSONArray;
import org.activiti.engine.impl.util.json.JSONObject;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import sun.misc.BASE64Encoder;
public class test implements TaskListener {
RestTemplate restTemplate = new RestTemplate();
String url = "http://localhost:8082/activiti-app";
@Override
public void notify(DelegateTask task) {
// TODO Auto-generated method stub
DelegateExecution execution = task.getExecution();
String cmplx=(String) execution.getVariable("complexity");
System.out.println("complexity="+cmplx);
String groupName="";
String groupId="";
HttpEntity<String> requestEntity = new HttpEntity<String>("", getHeadersForAPS());
if(cmplx.toLowerCase().equals("high")) {
groupName="high";
ResponseEntity<String> groupData = restTemplate.exchange(url+"/api/enterprise/groups?filter="+groupName, HttpMethod.GET, requestEntity, String.class);
System.out.println("groupData="+groupData.getBody());
JSONObject getSubGroupDataJson = new JSONObject(groupData.getBody());
JSONArray dataArray= getSubGroupDataJson.getJSONArray("data");
groupId = dataArray.getJSONObject(0).getString("id");
}
else if(cmplx.toLowerCase().equals("medium")) {
groupName="medium";
ResponseEntity<String> groupData = restTemplate.exchange(url+"/api/enterprise/groups?filter="+groupName, HttpMethod.GET, requestEntity, String.class);
System.out.println("groupData="+groupData.getBody());
JSONObject getSubGroupDataJson = new JSONObject(groupData.getBody());
JSONArray dataArray= getSubGroupDataJson.getJSONArray("data");
groupId = dataArray.getJSONObject(0).getString("id");
}
else {
groupName="low";
ResponseEntity<String> groupData = restTemplate.exchange(url+"/api/enterprise/groups?filter="+groupName, HttpMethod.GET, requestEntity, String.class);
System.out.println("groupData="+groupData.getBody());
JSONObject getSubGroupDataJson = new JSONObject(groupData.getBody());
JSONArray dataArray= getSubGroupDataJson.getJSONArray("data");
groupId = dataArray.getJSONObject(0).getString("id");
}
System.out.println("groupId="+groupId);
task.addCandidateGroup(groupId);
System.out.println("ggg="+task.getCandidates());
}
public MultiValueMap<String, String> getHeadersForAPS()
{
String alfrescoUserName = "admin@app.activiti.com";
String alfrescoPassword = "admin";
String authString = alfrescoUserName + ":" + alfrescoPassword;
String authStringEnc = new BASE64Encoder().encode(authString.getBytes());
MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();
headers.add("Accept", "application/json");
headers.add("Content-Type", MediaType.APPLICATION_JSON.toString());
headers.add("Authorization", "Basic " + authStringEnc);
return headers;
}
}
Regards
Amruta Wandakar
Explore our Alfresco products with the links below. Use labels to filter content by product module.