Update description with caller name

Ajitsure
Tera Contributor

Requirement : Description needs to be updated as caller name after update using business rule.

 

I have tried below code but its not working.

 

var gr = new GlideRecord('incident');
gr.addQuery('caller_id.name',current.caller_id.name);
gr.addQuery('description',current.description);
gr.query();
while (gr.next())
{
return current.description=current.caller_id.name;
}

7 REPLIES 7

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Ajitsure ,

On which table your are trying this ? if on incident then you can write down one line of code as

// Update the description field with the caller's name
current.description = current.caller_id.name;

 

Create before update BR on incident table with condition as caller changes. 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Hi Kiratkar,

 

Why cant we use after update BR?

Hi @Ajitsure ,

If you use after BR then you will have to use current.update() in script and that is not good practice at all.

So better to go with before update BR which can update the record before record gets updated into the database.


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Hi Kiratkar,

 

Can you please share me a piece of code using after BR