How to get the first related record in the business rule

Santoshi5
Giga Guru

Hi All,

I am stuck in middle, please help me to sort my issue,

for 1 problem if there are 5 incident records are related i want to get the first incident which is related to that problem and want to update some data in to that incident.

Let me know how to add the logic in the filter in business rule so i can get the first record only.

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

at which place you are writing this script?

BR? if yes then on which table?

Actually there is no field which can help you determine which incident was first linked with the problem

regards
Ankur

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

View solution in original post

10 REPLIES 10

i am writing a BR on asmt_assessment_instance  table from there i am populating some answers on Problem record similarly if there is any incident is tagged to that problem record i have to Glide it and need to populate some data in the incident as well.

 

yes correct, we don't have that field available directly , I  can see that date  stamp is available only in the activity log of that particular incident. 

 

 

Hi,

then you cannot easily know which was the 1st incident which was linked to that problem

you can pick any random one

Please share the script you started

Regards
Ankur

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

Aman Kumar S
Kilo Patron

Hey,

There is no straight ootb solution that can be applied here to figure out which problem was attached first with a incident since the relationships are maintained on incident table and not m2m table.

You might want to create a additional field on the incident, eg "Associated at" which will be of type Date time, which can be set via BR once problem field gets populated on incident form.

And now in your query on the basis of this new field you can orderBy to find the earliest one and then do what you want to do.

Again, its not a optimal solution but will fix what you are looking for

Best Regards
Aman Kumar

yes using this way we can implement it , but instead of making it custom i am looking for OOB functionality if there is any.

Unfortunately, no.

Best Regards
Aman Kumar