- 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 09:27 AM
I'll be doing something similar as I have more than 20 items I'll need to add this to. I guess I'll have to have a new name for each of these catalog scripts. Small price to pay for something that works! Thank heaven for Insert and Stay!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 09:36 AM
you can give them all the same name.. but a better idea might be to create a variable set with the reuqested for etc in it.. and this client sript. <and any others you put in all items> then just add the variable set tot he items when you create them... that way you only have one script to modify if you ever have to...
if the items are already created.. just open the client script... hit the dropdown to change to one of the other items.. and right click the title bar and select insert and stay.. that should create a new script with the same name on that item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 09:40 AM
Just as an fyi i actually have a catalog item that is inactive called "Template" it has the default variable sets and client scripts in it... that way when i need to create a new item i just choose copy from the toolbar <an insert wont' work here> and find the copy.. rename it, activate it and start building it out.. this prevents me from forgetting anything that goes into every item checkboxes that i always set the same etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 10:57 AM
That's a good technique. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 11:00 AM
no worries you may want to mark this one as answered so people don't bother reading it to help.