- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2021 03:35 AM
Dear leaders ,
Can someone please help me with script for updating related records Description in Risk statement.
below 2 screen shots are GRC risk statement and related list have risks.
We have requirement to update all risk description if risk statement description is changed.
1>
2>
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2021 03:57 AM
you can use these steps
1) Always use after update BR on table "sn_risk_definition" to update records on another table
Condition: Description Changes
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("sn_risk_risk");
gr.addQuery("statement", current.getUniqueValue());
gr.query();
while(gr.next()) {
gr.setValue('description', current.getValue('description'));
gr.update();
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2021 03:48 AM
Hi,
You can write BR on Risk Statement table which should goto Risks table -> Find all records which have Risk statement as current risk statement and then update their desc with current description
Something like
Script -
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('risks'); //Add risk table name here
gr.addQuery('risk_statement',current.sys_id);//Add correct field name here
gr.query();
while(gr.next())
{
gr.description = current.description;
gr.update();
}
})(current, previous);
Make sure you run this BR on Risk Statement table. Also add correct risk table name and risk statement field name
Hope this helps
Thank you
Prasad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2021 04:12 AM
Hi
Updated code with exact field names and table. Thank you Ankur for values
Before Update BR as I have mentioned above with below code
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sn_risk_risk'); //Add risk table name here
gr.addQuery('statement',current.sys_id);//Add correct field name here
gr.query();
while(gr.next())
{
gr.description = current.description;
gr.update();
}
})(current, previous);
Thank you
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2021 03:57 AM
you can use these steps
1) Always use after update BR on table "sn_risk_definition" to update records on another table
Condition: Description Changes
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("sn_risk_risk");
gr.addQuery("statement", current.getUniqueValue());
gr.query();
while(gr.next()) {
gr.setValue('description', current.getValue('description'));
gr.update();
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2021 03:58 AM
You can also use flow designer based approach with no script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader