How to print multiple variables' value to the description of target record in a record producer ?

1_DipikaD
Kilo Sage

Hi All,

 

How to print short description of record producer to the short description of target record in a Record producer.

Also want to print multiple variables value to the description of the target record one after another.

I tried the below script but still did not get the expected result :-

//(function executeRule(producer,current)
//{current.short_description = producer.short_description;})
var gr = current;
var shortdescription = gr.short_description;
gr.shortdescription = producer.short_description;
var des = producer.organization_name;
gr.description = " Organization Name :-" + des;
gr.description= des +"\nPoint of Contact at Third Party :-" + producer.point_of_contact_at_third_party;
gr.insert();
 
Thank you
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@1_DipikaD 

short description of record producer means this?

AnkurBawiskar_0-1738299292500.png

 

If yes then you cannot access it using producer.short_description. You will have to hard-code it

current.short_description = 'Your Short Description \n' + 'Organization Name :-' + producer.organization_name + '\n' + 'Point of Contact at Third Party :-' + producer.point_of_contact_at_third_party;

If both the variables are reference type then use getDisplayValue() to get the display value rather than sysid

current.short_description = 'Your Short Description \n' + 'Organization Name :-' + producer.organization_name.getDisplayValue() + '\n' + 'Point of Contact at Third Party :-' + producer.point_of_contact_at_third_party.getDisplayValue();

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

5 REPLIES 5

Community Alums
Not applicable

Hi @1_DipikaD 

you take a try of following systax in producer script:

 

current.short_description = producer.short_description;

 

 var description = "Variable2: " + producer.variables.variable1 + "\n"; description += "Variable2: " + producer.variables.variable2 + "\n";

current.description = description;

current.update();

It's giving javascript parse error on line 2. Also short description did not get printed . What if the variable is present in a variable set ?

@1_DipikaD 

try the script I shared below

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

Ankur Bawiskar
Tera Patron
Tera Patron

@1_DipikaD 

short description of record producer means this?

AnkurBawiskar_0-1738299292500.png

 

If yes then you cannot access it using producer.short_description. You will have to hard-code it

current.short_description = 'Your Short Description \n' + 'Organization Name :-' + producer.organization_name + '\n' + 'Point of Contact at Third Party :-' + producer.point_of_contact_at_third_party;

If both the variables are reference type then use getDisplayValue() to get the display value rather than sysid

current.short_description = 'Your Short Description \n' + 'Organization Name :-' + producer.organization_name.getDisplayValue() + '\n' + 'Point of Contact at Third Party :-' + producer.point_of_contact_at_third_party.getDisplayValue();

If my response helped please mark it correct and close the thread so that it benefits future readers.

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