Displaying a message on Incident form Load based on the linked related records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 04:19 AM
Hi,
I am currently working on the Incident form and want to display the records linked to it as a message on Incident form load.
Ex: I have a Related Records section in Incident form.
When some problem is linked to it, I want the following message to be shown when the Incident form is opened:
"PRB12345 has been attached to this incident".
where PRB number should be brought dynamically according to the one linked.
I am finding it difficult to solve this as I am very new to Servicenow. Please help me in solving this.
Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 04:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 06:11 AM
Hi Prudhvi,
You can use display business rule to show the message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 06:20 AM
Hi Prudhvi
On incident table,there is a reference field which is linking to problem, try below code in on display business rule.
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage("Problem linked to this ticket : "+current.problem_id.getDisplayValue());
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2018 10:03 AM
Hi Harsh and Midhun,
Thanks for the help. This has worked. Actually, in Related Records, I have Problem, Work Order and Change Request reference fields. So, I tried showing a message for all using below code:
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage("Problem record linked to this ticket : "+current.problem_id.getDisplayValue());
gs.addInfoMessage("Change Request linked to this ticket : "+current.rfc.getDisplayValue());
gs.addInfoMessage("Work Order linked to this ticket : "+current.u_work_order.getDisplayValue());
})(current, previous);
But, when a Work Order is not linked, it shows that message with a blank next to it. Instead, I want the entire line to be hidden. Below is the screenshot:
So, when any of the fields is empty, it should not show that particular line. I could have created 3 different BRs (1 for each) but that would show three different messages and need to cancel each of them. So, dropped from doing so.
Please let me know how to change the code to reflect this.