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

Never mind, I found it.


OK, I set it to two step.   On the second step, it does show the new requested for name correctly.


ok Great so we know now that the catalog item is setting up the cart correctly... and it is being reset down stream as the request is being created.. take a look at the br's on the catalog request, catalog item, and catalog task tables to see if you have a br there that is setting the requested to or affecting it.. also look at the history of the ticket created and see if it shows it being changed.


You're a genius!!!!   I over looked a business rule.   I deactivated it and now the process is working!   I can't thank you enough for working through this with me.


no worries at all just make sure that deactivating that BR doesn't break other items you need it for!! if it does you can put in some kind of condition to leave this one item out.



we put that set requested for script on EVERY item we create because a lot of our ordering is done by the office admin not by the people that need the item.