- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2016 08:08 AM
Is there a script available that copies the worknotes entered on a catalog task back to the parent RITM record? We are using the RITM record to provide status back to the users via the portal.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2016 08:15 AM
Hi James,
Nothing out of the box, but you could create a business rule that does this easily enough.
Name: Copy task work notes to RITM
Table: Task (sc_task)
Insert: checked
Update: checked
When: After
Advanced: checked
Condition: Work notes Changes (or in the condition field: current.work_notes.changes())
Script:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_req_item');
if (gr.get(current.parent)) {
gr.work_notes = current.work_notes;
gr.update();
}
})(current, previous);
You said work notes. Change to 'comments' where appropriate if that's what you meant.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2016 07:01 AM
Any time automatic state changes are (or are not) happening, the first place to check is what business rules are running.
Go to System Diagnostics> Debug Business Rules, then run your various tests and observe the output at the bottom of the form.
Debugging Tools Best Practices - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2016 08:16 AM
It appears this business rule is being skipped when the comment business rules are active. When I cut them off, it runs.
Business Rules OFF
08:40:13.750: Global ==> 'task closer' on sc_req_item:RITM0013077
Business Rules ON
09:03:37.628: Global === Skipping 'task closer' on sc_req_item:RITM0013080; condition not satisfied: Condition: new TaskStateUtil(current).runTaskCloser()
Task Closer BR
Still being relatively new to all this.. not for sure what I'm looking at here. So here's the whole block that happens right after the Push Tasks BR Rules are fired when they are on:
09:09:40.661: Global ==> 'Push Task Work Notes to RITM' on sc_task:TASK0012826
09:09:40.665: Execute before update business rules on sc_req_item:RITM0013080 before engines (order <1000)
09:09:40.665: Global === Skipping 'Task Active State Management' on sc_req_item:RITM0013080; condition not satisfied: Condition: current.state.changes() && current.sys_class_name != "dmn_demand" && current.sys_class_name != 'idea'
09:09:40.665: Global === Skipping 'Assign from Stock' on sc_req_item:RITM0013080; condition not satisfied: Condition: current.configuration_item.changes() && !current.configuration_item.nil()
09:09:40.665: Global === Skipping 'reassignment counter' on sc_req_item:RITM0013080; condition not satisfied: Condition: current.assignment_group.changes()
09:09:40.665: Global === Skipping 'Set Active Flag' on sc_req_item:RITM0013080; condition not satisfied: Condition: current.stage.changes() && (current.stage=="complete" || current.stage=="Request Cancelled")
09:09:40.665: Global === Skipping 'Stamp Approvals' on sc_req_item:RITM0013080; condition not satisfied: Condition: current.approval.changes()
09:09:40.665: Global === Skipping 'mark closed' on sc_req_item:RITM0013080; condition not satisfied: Condition: new TaskStateUtil(current).runMarkClosed()
09:09:40.665: Global === Skipping 'task closer' on sc_req_item:RITM0013080; condition not satisfied: Condition: new TaskStateUtil(current).runTaskCloser()
09:09:40.666: Global === Skipping 'task reopener' on sc_req_item:RITM0013080; condition not satisfied: Condition: new TaskStateUtil(current).runTaskReopener()
09:09:40.666: Finished executing before update business rules on sc_req_item:RITM0013080 before engines (order <1000)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2016 08:19 AM
Your work notes BR is running (as seen first). The others are all skipped because the conditions are not met.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2016 08:23 AM
Is Task Closer the BR that sets the RITM state to 'Closed Complete'.. that script I didn't really understand. I guess it's time for a HI Incident.. lol

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2016 08:29 AM
Mark closed just changes the active flag based on the task state (e.g. Closed Complete, Closed Incomplete, etc.)
Task closer sets the state to Closed Complete if the active flag changes.
I don't see either one saying "Close the parent RITM when all the child tasks are closed." You may need to write that one yourself.