Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Previous field value not available in Notification on CMDB table (cmdb_ci_business_app)

SunilkumarP1632
Tera Contributor

Hi Team,

 

I am working on a notification requirement for Business Applications (cmdb_ci_business_app) where an email should be sent when the Operational Status changes, including both FROM and TO values.

 

Configuration details:

 

Table: cmdb_ci_business_app

Notification trigger:

Send when: Record Updated

Inserted: Unchecked

Condition: Operational status changes

 

Email content:

Previous Status: ${previous.operational_status}
Current Status: ${operational_status}

 

Observed behavior:

Notification triggers correctly on update

Current status value is populated

Previous status value is blank, even though the field value is clearly changing

 

preview 

SunilkumarP1632_0-1768362447970.png

 

SunilkumarP1632_1-1768362489381.png

 

 

 

Expected behavior (example)

 

If a Business Application has:

Operational Status = Operational

 

And it is updated to:

Operational Status = Non-Operational

 

Then the notification email should contain:

Previous Status: Operational
Current Status: Non-Operational

 

 

 

please help me here how to fix this 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@SunilkumarP1632 

you can't use Previous object in notification body directly

Other way

-> after update BR on cmdb_ci_business_app, Condition: Operational status changes

Script:

(function executeRule(current, previous /*null when async*/) {

    var oldStatus = previous.operational_status.getDisplayValue();
    var newStatus = current.operational_status.getDisplayValue();
  
    var param1 = "Previous Status: " + oldStatus + "<br/>" + "Current Status: " + newStatus;

    // Trigger the event, passing the data
    gs.eventQueue('your_event_name', current, param1, current.assigned_to); // Create 'your_event_name' in System Policy > Events

})(current, previous);

-> create event on that table and use that in BR script

-> also create notification on your table and make it trigger on your Event

-> Event parm2 contains recipient - True and this is the recipient to whom email will be sent

AnkurBawiskar_0-1768366376651.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron

@SunilkumarP1632 

you can't use Previous object in notification body directly

Other way

-> after update BR on cmdb_ci_business_app, Condition: Operational status changes

Script:

(function executeRule(current, previous /*null when async*/) {

    var oldStatus = previous.operational_status.getDisplayValue();
    var newStatus = current.operational_status.getDisplayValue();
  
    var param1 = "Previous Status: " + oldStatus + "<br/>" + "Current Status: " + newStatus;

    // Trigger the event, passing the data
    gs.eventQueue('your_event_name', current, param1, current.assigned_to); // Create 'your_event_name' in System Policy > Events

})(current, previous);

-> create event on that table and use that in BR script

-> also create notification on your table and make it trigger on your Event

-> Event parm2 contains recipient - True and this is the recipient to whom email will be sent

AnkurBawiskar_0-1768366376651.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@SunilkumarP1632 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

SunilkumarP1632_6-1768533384552.png

 

working but - bugs are there where i need to fix this @Ankur Bawiskar 

@Ankur Bawiskar 

 

As you suggested - 

i have created an event 

Business rule 

modifiyed the notiication 

 

SunilkumarP1632_0-1768532332553.png

SunilkumarP1632_1-1768532368679.png

 

 

event 

SunilkumarP1632_2-1768532399533.png

 

 

SunilkumarP1632_3-1768532482661.png

SunilkumarP1632_4-1768532514614.png

 

 

Result :- 

 

SunilkumarP1632_5-1768532556918.png

 

 

 

could you please help me here - what was the mistake happend . 

@SunilkumarP1632 

why sysId is coming?

is the field name correct operational_status on that table?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader