Order Guide - Requested for
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2008 07:53 AM
I would like to ask in the first step of an order guide the "requested for" user.
I tried to create the following variable:
- name: requested_for
- type: Reference
- Reference: sys_user
- mandatory
(Cascade Variables is ON)
But when you check out, the "Requested for:" field is still the curent user name...
Any idea?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2012 09:25 AM
I was trying to do this very thing, found this post and it was very helpful. Since AJAXEvaluateSynchronously has been replaced with GlideAjax, I updated these scripts to use GlideAjax and thought I'd share them.
Catalog Client Script, attached to order guide, onchange for the requested_for variable:
function onChange(control, oldValue, newValue, isLoading) {
if(oldValue != newValue){
var uid = g_user.userID;
var rf = g_form.getValue('requested_for');
//alert('rf = ' + rf + ' uid = ' + uid);
var ga = new GlideAjax('SetReqFor'); // calls the SetReqFor script include
ga.addParam('sysparm_name','setReqFor'); // launches the setReqFor function from the script include
ga.addParam('sysparm_uid',uid); // passes the uid of the currently logged in user
ga.addParam('sysparm_rf',rf); // passes the requested_for user
ga.getXML(); // we don't actually need any data back from the server for this to work
}
}
Script Include, must be named SetReqFor
var SetReqFor = Class.create();
SetReqFor.prototype = Object.extendsObject(AbstractAjaxProcessor, {
setReqFor: function() {
var answer = false;
var rfr = new GlideRecord("sc_cart");
rfr.addQuery("name", "DEFAULT");
rfr.addQuery('user',this.getParameter('sysparm_uid')); // will locate any currently open carts with the currently logged in user
rfr.query();
if (rfr.next()) {
rfr.requested_for = this.getParameter('sysparm_rf'); // updates the requested_for on the cart to the value passed by the client script
rfr.update();
answer=true;
}
return answer; // we don't need to do anything with this
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2014 01:30 PM
Thank you, your script helped me out!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2014 05:44 AM
Frederik, were you able to get this to work with the script "As is" ?
I mean, I've tried it, and can't get my cart updated using the catalog client script and the script include provided above.
If you had to change anything, would you mind sharing please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2015 06:00 AM
Thanks for that, solved our problems too!
BTW Jean-Francois, Zach's scripts (note there are two) worked out of the box for us. I suggest checking you associated the first one (catalogue client script) with the catalog item, I've included a screen shot of what we have used for settings. You'll also need to change the reference to the field, eg the field we wanted to use was called 'u_b_name' so the relevant line Zach's code was changed to: var rf = g_form.getValue('u_b_name');
The second one, which is under Script Includes, has to be called 'SetReqFor'.