Copy variables from Catalog Item into Request form fields?

mitzaka
Mega Guru

Hi SNC,

 

I use a catalog item which has a couple of variables for Short Description/Description. I managed to get them copied into the RITM, but I need a way to copy them into the Request (REQ) which is initially created after submission, because the first notification is actually based off the sc_request table and I need to provide users with the variable content in this first notification.

 

What's the easiest way to do this?

Thanks!

1 ACCEPTED SOLUTION

In my case where I wanted the Short Description field copied from variable into form, the final solution was an AFTER business rule on Requested Item table with the following script:



var request =current.request.getRefRecord();


request.short_description = current.variables.short_description;



Note: the name of my variable is short_description as well.


So that worked perfectly.


View solution in original post

22 REPLIES 22

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I would write a mail script in the notification that goes out from the request. You could query the requested item tables and the items and their variables and print them into you notification.



If you want to add the variables of the items into the notes of the request, you could do it in an after insert business rule on the item that copies the variables into the request.


Kalaiarasan Pus
Giga Sage

use may use getRefRecord in a after insert BR on requested item table and use something like this....



var request =current.request.getRefRecord();


request.anyField = current.variables.variableName;


request.update();



this may not be the most efficient way to do and would do the job for you


Kalaiarasan P this is not working exactly right. It does copy the fields, but the problem is for some reason it ends up in creating duplicate REQs.


have you used a before rule or a after rule? should not create duplicate request if you are using the after rule....