- 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-08-2014 07:44 PM
Anthony,
You need to create a OnBefore Business Rule.
myFunction();
function myFunction() {
var rItem = new GlideRecord("sc_req_item");
rItem.addQuery('request', current.sys_id);
rItem.query();
if (rItem.next()){
current.requested_for = rItem.variables.NameOftheItemvariableName;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 06:57 AM
Steven, I need to change the filed Requested for in the Request [sc_request] table. This way it will cascade down to the RITM and TASK tables too. Not sure if your solution does this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 07:00 AM
Hi Anthony,
Just change the table name. that should do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 07:04 AM
did you try adding the on change script i put in above.. this should be set to run when the requested for variable changes and should accomplish what you are after...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2014 07:32 AM
I'm still unclear about what you sent me. Did you see my response to your original reply?