How to update description field in incident table from specific catalog item's variable ?

Bishal Sharma
Tera Contributor

Hi,

 

Any idea on how to auto populate description field in incident form from particular catalog item's variable.

 

I have written a business rule:

 

When to run: After Insert

Advance: 

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

var gr = new GlideRecord("incident");

gr.addQuery("sys_id=552c48888c033300964f4932b03eb092");

gr.query();

while (gr.next())

{
gr.description = current.variables.short_description;
}

current.update();
})(current, previous);

 

Thank in advance.

1 ACCEPTED SOLUTION

Hi,

so you have set the BR as after insert

on which table and how is this BR triggered?

try this

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

var gr = new GlideRecord("incident");

gr.addQuery("sys_id=552c48888c033300964f4932b03eb092");

gr.query();

if(gr.next())

{
gr.description = current.variables.short_description;

gr.update();
}


})(current, previous);

Regards
Ankur

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

View solution in original post

7 REPLIES 7

Palak Gupta
Tera Guru
Tera Guru

Hi,

Are you trying to update any specific incident? If yes, then what is "When to Run" condition setup to?

Regards,

Palak

Hi Palak,

 

Yes, I am trying to update a specific record in incident table.

 

When to Run is set to After Insert

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Do you want to set description of the incident which got submitted with the description variable

are you sure the incident got generated as part of some record producer?

if yes then are you giving correct variable name?

no need to query then

you can directly use record producer script

current.description = producer.short_description;

Regards
Ankur

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

Hello,

 

No, the incident is not generated from catalog item. 

 

I just need to update the description field in incident form from the value available in short description variable which is present in Task - 1 catalog item.