- 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-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-02-2020 07:43 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2020 11:42 PM
The wait for condition in the WF will execute only when the underlying table defined in the workflow is updated everytime. If catalog task is closed then the wait for conditons which was defined on request table will not execute. Hence you need a Br on catalog task which updates the request whenever a task is closed.
Once the request is closed, then the WF wait for conditions runs and in that you can also close the ritm along with closing the request.
Mark the comment as a correct answer and also helpful if this helps to solve the problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2020 06:43 AM
Hi there,
Within the script field of the Create Task, you could set up a scratchpad. Just using something like:
workflow.scratchpad.something = task.number;
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2020 07:04 AM
My ultimate goal is to close the request once the task is closed complete and this should all be performed in the workflow.
Would I do what you said but instead change the value to:
workflow.scratchpad.something = task.state;
Then in the next flow add an IF statement, state changes to closed complete set state on REQ to closed complete?