Populating the Location field on a Request form from a catalog item via code

BigMikeyVegas
Tera Guru

I have created a catalog item using maintain items. One of the variables is 'If a single property, which property is the request for?'. The variable name is location. I tried mapping it using :

gr.requested_for.location = current.variable.location;
1 ACCEPTED SOLUTION

BigMikeyVegas
Tera Guru

Close, the correct answer is :

gr.location = current.variables.requested_for.location;

View solution in original post

5 REPLIES 5

SanjivMeher
Kilo Patron
Kilo Patron

Are you trying to copy the value in the location variable to location in request. If so, you can do it using

 

gr.request.location = current.variables.location;

 

provided gr is the object you created for sc_request table and this is a business rule running on sc_req_item


Please mark this response as correct or helpful if it assisted you with your question.

BigMikeyVegas
Tera Guru

this is the entirety of the code, which is found in a 'run script' in the workflow. I added the above script, but no joy. 

 

var gr = new GlideRecord('sc_request');
if (gr.get(current.request))  {
   gr.short_description = current.cat_item.getDisplayValue() + " for " + current.variable.InfoGOutlets.getDisplayValue();
	gr.assignment_group = current.assignment_group;
	gr.requested_for = current.variable.requested_for;
	gr.request.location = current.variables.location;
	   gr.update();
   }

SanjivMeher
Kilo Patron
Kilo Patron

Ok.. Got it. Use below code. This script should be on Requested Item table

 

var gr = new GlideRecord('sc_request');
if (gr.get(current.request))  {
   gr.short_description = current.cat_item.getDisplayValue() + " for " + current.variable.InfoGOutlets.getDisplayValue();
	gr.assignment_group = current.assignment_group;
	gr.requested_for = current.variable.requested_for;
	gr.location = current.variables.location;
	   gr.update();
   }

 

 


Please mark this response as correct or helpful if it assisted you with your question.

Thank you again. I really appreciate your assistance.