Hi Rob,
I have checked but not found my “sampleOrderId” variable in my REST response in process variables. I am attaching the implementation here below. Can you please suggest where I am mistaking?
ServiceTask1 Code
public void execute(DelegateExecution execution) throws Exception {
RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
String randomOrderId = generateOrderIdSample();
execution.setVariable(“sampleOrderId”,sampleOrderId);
runtimeService.setVariable(execution.getProcessInstanceId(), “sampleOrderId”, randomOrderId);
}
private String generateOrderIdSample()
{
// create instance of Random class
Random rand = new Random();
// Generate random integers in range 0 to 999
int rand_int1 = rand.nextInt(1000);
return Integer.toString(rand_int1);
}
REST Request is -
{
“orderName”:“Order1”,
“orderId”:"",
“orderType”:“New”,
“withVariablesInReturn”: true
}
REST Response is -
{“context”:{“headers”:{},“entity”:“efef6f50-da26-11ea-a72d-c85b76191d47”,“entityType”:“java.lang.String”,“entityAnnotations”:[],“entityStream”:{“closed”:false,“committed”:false},“length”:-1,“language”:null,“location”:null,“date”:null,“lastModified”:null,“mediaType”:null,“committed”:false,“acceptableMediaTypes”:[{“type”:"",“subtype”:"",“parameters”:{},“quality”:1000,“wildcardSubtype”:true,“wildcardType”:true}],“acceptableLanguages”:["*"],“requestCookies”:{},“responseCookies”:{},“allowedMethods”:[],“entityTag”:null,“links”:[],“stringHeaders”:{},“lengthLong”:-1,“entityClass”:“java.lang.String”},“status”:200,“length”:-1,“language”:null,“location”:null,“date”:null,“lastModified”:null,“metadata”:{},“mediaType”:null,“entity”:“efef6f50-da26-11ea-a72d-c85b76191d47”,“allowedMethods”:[],“cookies”:{},“statusInfo”:“OK”,“entityTag”:null,“links”:[],“stringHeaders”:{},“headers”:{}}
Thanks in Advance,
SG