Requested For' in Service Catalog

harish11
Mega Expert

HI All,

Am having a similar issue here. I have a 'Requested for' field which is part of a variable set. Now when a request is submitted the requested for' in the request form is different to the 'Requested for' variable. (Hope this makes sense). So i browsed through the community site for a business rule to set this up. I applied the following

function onBefore(current, previous) {

var grRITM = new GlideRecord('sc_req_item');    

grRITM.addQuery('request', current.sys_id);    

grRITM.query();    

while (grRITM.next()) {    

  if (!JSUtil.nil(grRITM.variables.requested_for)) {    

      current.requested_for = grRITM.variables.requested_for;  

  }    

}  

}

which doesnt seem to be working. Can anyone help with what I could be doing missing

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Harish,



It is working. Please check in the below instance.


https://demo007.service-now.com/login.do


Username : admin


Password : admin


Testing steps : Catalog item : Access


Is it possible because I have set the default value of that field to populate the user name (see attached screenshot of the variable field).



I am using this variable set for other items. So i set a general default value for the field to auto populate.



Apart from this, dont see what else could stop it from working.. Screen shot 3.jpgScreenshot 5.jpg


HugoFirst
Kilo Sage

I feel like I'm missing something here.


Did you try the following command?



current.requested_for = current.variables.requested_for;




(I'm assuming this is in a business rule for the request record, since requested_item does not have a requested_for field.)


Hi Steve @ Its working now, Unable to mark Pradeep's reply as Correct Answer, as I started this as a discussion and not as a question.



But one of things we have identified (and this could be a bug) is we need to refresh the browser everytime a rule is setup. Only then does the applied change works.