Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

GlideRecord usage in business rules

Tomas Linde
Tera Expert

Hi everybody i have a problem with this story, I am a junior Developer and now i start with the ServiceNow Certification and I need a little bit of your help for this Story:

 

As an ITIL User
I WANT that when an incident is closed (state changes to Closed), the system goes through active incidents with the same Short Description and add the following work note:
"Please note that incident " + [INCIDENT NUMBER] + " with the same Short Description has been closed"
So that similar incidents than the one that I am closing have additional information and may leverage the solution.

 

I know this is complete when active incidents with same short description than the incident that I am closing get a worknotes as mentionned in the story description. 

 

Thanks for your help.

2 ACCEPTED SOLUTIONS

priyasunku
Kilo Sage

@Tomas Linde 

 

write an after business rule on incident table

 

condition: state changes to closed

 

script

 

var gr = new GlideRecord('incident');

gr.addActiveQuery('short_description',current.short_description);

gr.query();

while(gr.next())

{

gr.work_notes="Please note that incident  " +current.number+ "  with the same Short Description has been closed".

gr.update();

}

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

 

View solution in original post

@Tomas Linde  if my answer helped you. please mark it as correct.

View solution in original post

5 REPLIES 5

priyasunku
Kilo Sage

@Tomas Linde 

 

write an after business rule on incident table

 

condition: state changes to closed

 

script

 

var gr = new GlideRecord('incident');

gr.addActiveQuery('short_description',current.short_description);

gr.query();

while(gr.next())

{

gr.work_notes="Please note that incident  " +current.number+ "  with the same Short Description has been closed".

gr.update();

}

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful

 

@Tomas Linde  if my answer helped you. please mark it as correct.

Thank you so much for the help.

@Tomas Linde please mark the answer as correct.