How to get SCTASK number in workflow

mkader
Kilo Guru

Hello,

I have a workflow on sc_request table that creates an sctask. It is a simple workflow:

Begin > Create Task > End

I want to store the value as a workflow scratchpad or a set value so that when the sc_task is closed, I can close a RITM being created through another workflow on the same REQ. 

Thanks!

1 ACCEPTED SOLUTION

Okay.

The WF will not know if the task is closed as WF is runnig on request table. So you nee dto update the request for the WF code to run.

May be you can do1 thing. Use the Br tht i  gave when task is clsoed update the request work notes.

Then in your workflow add  a wait for condition

// Set the variable 'answer' to true or false to indicate if the condition has been met or not.
var flag=0;
var gr = new GlideRecord("sc_task");
gr.addQuery("request",current.sys_id);
gr.query();
while(gr.next()) {
  if(gr.state == 3) {     
     flag++;    
  } 
}
if(flag == gr.getRowCount()) {
  answer = true;
} else {
  answer = false;
}

Then link the set values activity and make the request as closed.

The Wait for condition will run when the request is updated. And you update the request with the BR on sc_task table.

View solution in original post

13 REPLIES 13

Mike Patel
Tera Sage

before end add run script with below script

var gr = new GlideRecord("sc_task");
gr.addQuery("request", current.sys_id);
gr.query();
if (gr.next()) {
    workflow.scratchpad.number = gr.number;
}

@Mike Patel - If I wanted to close the REQ if SCTASk is closed complete how would I do that?

 

 

Hi

You can write a BR on sc_task

conditon 

state changes to closed

var gr = new GlideRecord("sc_request");

gr.addQuery("request",current.request);

gr.query();

if(gr.next()) {

gr.state=3; //put right feild and values

gr.update();

}

 

@asifnoor - Thank you for your response. I was advised by my team to keep this within the workflow