- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2020 06:33 AM
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!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2020 07:21 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2020 12:50 AM
Hello USer,
Try the below one.
var arr=[];
var gr = new GlideRecord("sc_task");
gr.addQuery("request", current.sys_id);
gr.query();
while (gr.next()) //dont use if,if will give you only one task number.what if you have utiple task so use while
{
arr.push(gr.getUniqueValue();
//workflow.scratchpad.num = gr.number;
}
Please Mark it helpful/correct if my answer helps in any way to resolve your query.
Reach out to me if any more help required.
Regards
Yash.K.Agrawal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2020 04:57 AM
Heello mkder
As said,if condition will give you only one task numner.while will give you all the task number which have same request.
Dont you think the same?
Please keeep posted for more help
Regards
Yash Agrawal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2020 01:11 AM
Hi
In addition to Yash,I would like to add some my views as
var sc_task = new GlideRecord('sc_task');//Glide the sc_task
sc_task.addQuery('request_item',current.sys_id);//your requested ,request item is this ritm
sc_task.OrderByDesc('sys_created_on');//
sc_task.setLimit(1);
sc_task.query();
if(sc_task.next()){
workflow.scratchpad.sc_task = sc_task.number;
}
after this you will have to refer to workflow.scratchpad.sc_task to get that sc_task's value;
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2020 02:19 AM
Hello,
Basically for you to close the request which created the sc task you need to add a wait for condition with a script checking the state of the sc task after you getting the sc task through scratchpad, once the closing condition is met you could close the request.
Putting if condition will not work as it will check the current value and complete the workflow.
Hope this helps!
If my answer helped you in any way, please then mark it as helpful.
Regards
Aishwarya Thevar