Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How to populate alert open date on 'Detection Time' field in the incident form.

ashok17
Tera Contributor

How to populate alert open date on 'Detection Time' field in the incident form when ever alert attached in the incident. 

 

I have tried below before Business Rules script but doesn't works: Please suggest

 

// If an alert is attached to the incident
if (current.alert) {
var alertGR = new GlideRecord('em_alert');
if (alertGR.get(current.alert)) {

// Set Detection Time to the alert's opened_at value
current.u_detection_time = alertGR.opened_at;
}

4 REPLIES 4

Ankur Bawiskar
Tera Patron

@ashok17 

BR is on which table?

what debugging did you do?

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

BR is Incident table:

 

Requirement was If incident have alert attached then the alert open date should be auto populate on 'Detection Time' field in the incident.

AlpUtkuM
Mega Sage

Why don't you use flow for the requirement?

 

Flow Trigger : Incident created or updated

 

Lookup records where Incident is active and Alert is not empty

 

Use for each loop to go through the records

 

If count > 0

 

Use Update Record action to auto populate Detection Time field

 

You could check the similar logic here : https://www.servicenow.com/community/itsm-forum/flow-designer-search-for-incidents-that-has-attachme...

ashok17
Tera Contributor

Thanks for response,

 

But how we will map condition flow on alert attached incident then only detection time updated?

 

Thanks,

Ashok