- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015 07:06 AM
I have a catalog item that creates a RITM and TASK and, depending on the disposition of the task, may or may not require that a Change be created.
I've added the UI Action for "Create Change" to the right click menu, and this does work, but I really don't want this ability available for all requests, and I'd actually like to work the change creation from the workflow, where I can send specific information to the change and assign it automatically.
There's a variable on the form "Create Change?" Yes/No/None. I tried an "IF" and a "Wait For Condition" in the workflow, but neither one responds to the update of this variable on the task.
The issue may be that the RITM and TASK are created by one person, and later updated by someone else (where the Create Change variable may or may not be updated). It appears that the workflow doesn't see the update to the Task.
Here's the script for the If and the Wait for Condition. It's OOB. It doesn't trigger the Create Change task when I check the box and update the form. Of course, if I simply modify this to say "answer = true" the workflow progresses as I want it to, but the needed condition is not addressed.
answer = ifScript();
function ifScript() {
if (current.variable_pool.ccb_changecreate == 'true' ) {
return 'true';
}
return 'false';
}
Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2015 03:31 PM
Wanted to post the resolution for this item. After continuing to work this I came up with a very clunky solution--to have the workflow create a task, which, when closed, would trigger the create of the change. Works, but oh so awkward. In thinking about this and brainstorming with a colleague, we came up with using the approval process.
This is working really well, to the point of automatically closing the RITM when the Change is closed. Super simple, works great. I took off the checkbox for "Wait for Completion" on the Task.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015 07:16 AM
When the task is updated , you either need to issue a update statement to your RITM or invoke the workflow engine... Workflow engine does not listens to change to task directly ...
Script to invoke the engine manually ...
function forceReqItemUpdate() {
var wf = new Workflow();
var ri = new GlideRecord("sc_req_item");
if (ri.get(current.request_item)) {
wf.runFlows(ri, 'update');
}
}
This would either go in the UI action or a business rule on catalog task table...
Refer:
Condition Activities - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015 12:46 PM
Kalai,
Thanks so much for your quick response. I created a business rule on the catalog task table, and tested the item again, but the workflow still did not proceed.
I'm looking at the whole thing again to see if I've made any mistakes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015 02:29 PM
I am a little confused by how you want that to work... can you post the workflow showing where that if/then is in your workflow?!
remember if thens only act at that specific point in the workflow
the other thing to consider is how you want your change to get created in the workflow... the preferred method is a create task... you can point this at the change table and map all the fields you need in it for your change...
this works great as long as you don't need y our workflow to proceed when that change hits a specific stage... <that branch of the workflow will sit there till the change is closed before continuing>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2015 12:14 PM
Hi Doug, thanks for your response. I vacillate between an if/then and a wait for condition activity. Right now the workflow is using a Wait for condition activity. I'm not concerned about whether or when the change gets closed (once created it will follow the Change workflow), and I do know how to map the data that I need from the task variables to the change record.
The current script in the wait for condition is this:
answer = ifScript();
function ifScript() {
if (current.variable_pool.ccb_changecreate == 'yes' ) {
return 'true';
}
return 'false';
}
I also created the business rule suggested by Kalai as follows.
Hopefully whatever is missing will be clear as day to you all. Thanks again for looking.