- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 03:38 AM
Hello Team,
I have a reference field ("") on Problem ticket, which has an Incident Number (PFA) from Incident table. I want to set the value of "Contact type" field to "None" on Incident Form of this old Incident, whenever the Incident Number changes to a new incident on Problem ticket form.
Please help me on how to capture the SysID of the previous incident in "o set the value of "Contact type" field to "None" on the Previous incident .
I wanted to use , Before Business rule for the same. But I am not sure how can we capture the previous values of a reference field using previous object .
Thank you!!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 04:04 AM
Hi Pravalika,
Write After business rule on problem table like below
Condition :
current.first_reported_by_task != previous.first_reported_by_task
Code :
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage('Current '+ current.first_reported_by_task + ' Previous '+ previous.first_reported_by_task);
// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', previous.first_reported_by_task);
gr.query();
if(gr.next())
{
gs.addInfoMessage("Going inside");
gr.contact_type = '';
gr.update();
}
})(current, previous);
Screenshot of condition and code :
Mark my answer as correct or hit like
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 03:49 AM
If you are not familiar with coding, you could achieve this using Flow Designer.
Trigger: Problem is updated
Condtion: First reported by changes and Firest reported by is not empty
- Action:Update Record (Problem.First reported by)
- Contact type = none
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 03:50 AM
If you are set on business rules, you must use an after rule.
It is generally considered best practice to consider low/no code approaches first.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 04:04 AM
Hi Pravalika,
Write After business rule on problem table like below
Condition :
current.first_reported_by_task != previous.first_reported_by_task
Code :
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage('Current '+ current.first_reported_by_task + ' Previous '+ previous.first_reported_by_task);
// Add your code here
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', previous.first_reported_by_task);
gr.query();
if(gr.next())
{
gs.addInfoMessage("Going inside");
gr.contact_type = '';
gr.update();
}
})(current, previous);
Screenshot of condition and code :
Mark my answer as correct or hit like
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2022 12:18 AM
Hi,
If your issue is resolved, Please mark my answer as correct and close the thread.
Regards
Regards,
Musab