How to Override Default for Requested For Field

ajlabate
Kilo Expert

The Requested for field is always set to whoever is creating the request (the person presently logged in).   I'm trying to make it something different and all my attempts have failed.   Ultimately, I'd like it to be the name of the person that is entered into the Variable (Requested for).   I checked the dictionary for the field and saw that it had a default value as javascript:gs.getUserID()     I removed this default value but the field gets set anyway.   I tried to set it in the beginning of the workflow with a Run Script activity to the variable entry submitted by the user but that does nothing.   No matter what I do, the field is always set to the person entering the request.   I need that person to be able to designate someone else as the requested for person.   Any ideas?

 

This is the script in the workflow:

var reqRecord = current.request.getRefRecord();

reqRecord.requested_for = current.variable_pool.requested_for;

1 ACCEPTED SOLUTION

yes sir.. just replace the entire script with the below and it should work like magic.



___________________




function onChange(control, oldValue, newValue, isLoading) {


   


    if (newValue){


          var gr = new GlideRecord('sc_cart');


          gr.addQuery('user', g_user.userID);


          gr.query();


          gr.next();


          gr.requested_for = newValue;


          gr.update();


    }


}


View solution in original post

55 REPLIES 55

interesting on the checkout screen is the requested for correct or incorrect?


we need to figure out if the cart is getting set correctly and then changed when the request is created or if it is wrong at the cart level...


Here's the before screen shot:


SC Req - Before.jpg


Here's the after:


SC Req - After.png


ok do you have two step checkout enabled so that when they submit that they end up on a checkout screen that shows all of the requested items?? if so on that screen is the requested for the same as the requested for   on the item.. if not you may want to enable it long enough to check this.. it will let you know who the requested for on the cart is and provide a checkpoint to see where requested for is being reset.


For this item there is not a two-step checkout.   Where do I change it to be two-step?