- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2018 11:18 AM
Hi,
Not working my BR script
After
Condition: current.work_notes.changes()
var updateInitiatedBy = updateInitiatedBy || current.sys_id.toString();
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(updateInitiatedBy == current.sys_id.toString()){
var gr = new GlideRecord('incident');
gr.addQuery('problem_id',current.sys_id);
gr.query();
while(gr.next()){
gr.work_notes = current.work_notes;
gr.update();
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 04:59 AM
Or you can use the same Business Rule as for Incident Work notes -> simply specify a second variable:
(function executeRule(current, previous /*null when async*/) {
// This Business Rule ensures that if there is a Parent Problem record, which has one or more Incidents records associated to it as Child Incidents or Problem Task(s) -> then, whenever the Work notes of the Problem get updated -> the Work notes of all Child Incidents & Problem Tasks will be updated accordingly with the same text;
// var rec = Child Incident(s);
var rec = new GlideRecord("incident");
rec.addQuery("problem_id", current.sys_id);
rec.addActiveQuery();
rec.query();
while (rec.next()) {
rec.work_notes = "Incident Work note copied from Parent Problem" + ':' + current.work_notes.getJournalEntry(1); // //Choose a text of your own, which suits you;
rec.update();
}
// var prtask = Child Problem Task(s);
var prtask = new GlideRecord("problem_task");
prtask.addQuery("problem", current.sys_id);
prtask.addActiveQuery();
prtask.query();
while (prtask.next()) {
prtask.work_notes = "Problem Task Work note copied from Parent Problem" + ':' + ' ' + current.work_notes.getJournalEntry(1);
prtask.update(); //Choose a text of your own, which suits you;
}
})(current, previous);
Best Regards,
Georgi Mavrodiev
IT Consultant
Do IT Wise Bulgaria
You may visit us in our Web Site: www.doitwise.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 08:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 08:58 AM
Chanikya,
Please read my above update carefully.
I explicitly mentioned explicitly what you should do in case of duplication or the same situation in which you are in.
To deal with it - update the Conditions of both Business Rules: Advanced > Condition: current.work_notes.indexOf('###')<0
And add ### into the texts lines of their scripts like
By updating the BRs with the above changes -> you will ensure that no duplication of the work notes will appear in the Parent Problem or its Child Incidents & Child Problem Tasks. Also, you will ensure that when a Problem Task work notes get updated to its Parent Problem -> these work notes will not be also updated in any other of Child Problem Tasks or Child Incidents.
Best Regards,
Georgi Mavrodiev
IT Consultant
Do IT Wise Bulgaria
You may visit us in our Web Site: www.doitwise.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 09:58 AM
Thanks for your Clarification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 12:31 PM
Chanikya,
I suppose this query of yours has been covered.
If so, then I will appreciate if you mark the treat as completed by selecting a correct answer, so other members may use the topic for references in future cases.
Thanks!
Best Regards,
Georgi Mavrodiev
IT Consultant
Do IT Wise Bulgaria
You may visit us in our Web Site: www.doitwise.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 10:10 AM
can you help me on this thread
every thing is working perfect , but small issue..
https://community.servicenow.com/community?id=community_question&sys_id=2a700af2db9797402be0a851ca9619d2