How to pass variable values from catalog item to request table?

akriti2
Kilo Contributor

Hi all,

I have a basic question. I have a catalog item and   have created a variable called requested for(requested_for) on the catalog item. The value of this field needs to be passed to the requested for field(requested_for) on the request table (sc_request). How do I achieve this?

As you can see in the below screenshot, requested for value is Abel tutor in the catalog item form. I want this value to be passed to the request table instead of System Administrator. Please help.

Thanks & Regards,

Akriti

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Sorry, this script should be on sc_request table and change it from after to before business rule and put this script in there. You are good to go



var gr= new GlideRecord("sc_req_item");


  gr.addQuery('request',current.getValue("sys_id"));


  gr.addQuery("item.name","put your item name here");


  gr.query();


  if(gr.next()){


  current.requested_for=gr.variables.requested_for;


  }


View solution in original post

7 REPLIES 7

Hello Abhinay ;

I am new to servicenow.

I tried the same script but something is going wrong please can you help me out.

Abhinay Erra
Giga Sage

Let me if I have answered your question. If yes, please mark my response so that others who have same question can find the answer quickly.



If you are viewing this from the community inbox you will not see the correct answer button. Please open the thread directly, then you should see a Correct Answer button with red star.


Abhinay Erra
Giga Sage

You bet!! Glad you got your question answered.