- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2014 10:02 AM
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;
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 08:00 AM
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();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 07:47 AM
The variable I use never changes. It is always called requested_for. I copied your script into a client script that I named "Set_Req_For". The Type is onChange, Table is sc_request, Field name is Requested for. Where do I call out this new script? Is it in the beginning of the workflow? And how do I reference it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 07:50 AM
this is on a catalog item correct?! so it goes on the catalog item itself in the catalog client scripts area sorry if i wasn't clear on that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 07:57 AM
Yes it is. Do I overlay what is already in the Script area?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 08:00 AM
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();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 08:06 AM
I tested it, but the Requested for field is blank. I didn't change the script at all. Should I try replace newValue to something else here?:
gr.requested_for = newValue;