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
‎09-24-2008 11:27 PM
Hi Sylvain,
The Requested_for is set on the 'cart' and is normally only controlled via the 'requested_for' widget on the front page of the catalog. This does make sense: you either order for yourself or for someone else, never combined.
To cut a long story short:
We use a global client script / global script to set the requested_for on the cart when selecting it in a field you just described. The code is below.
function onChange(control, oldValue, newValue, isLoading) {
if(oldValue != newValue){
var uid = AJAXEvaluateSynchronously("gs.getUserID()");
var rf = g_form.getValue('requested_for');
//alert('rf = ' + rf + ' uid = ' + uid);
var script = "setReqFor('" + uid + "','" + rf + "')";
var answer = AJAXEvaluateSynchronously(script);
}
}
function setReqFor(uid, rf) {
//gs.addInfoMessage('UID is ' + uid + ' RF is ' + rf);
var answer = false;
var rfr = new GlideRecord('sc_cart');
rfr.addQuery('name', 'DEFAULT');
rfr.addQuery('user',uid);
rfr.query();
if(rfr.next()){
rfr.requested_for = rf;
rfr.update();
answer = true;
}
return answer;
}
Good Luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2008 12:47 AM
Yes! That is exactly what I was looking for. It works perfectly:D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2009 09:19 AM
Hi, I am trying to use this example to do the same thing. I have a Catalog Item and I ask who the request is for. The variable is global and I named it requested_for. However, when I complete the request the requested_for is still set to the person currently logged in. Question... the global script is on what table?
I have it onChange- sc_cart - requested_for.
Thanks-Michele
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2015 01:49 PM
I am still struggling with this. I don't quite understand what to attach the onChange code to.
In this thread, people are suggesting that I attach it to the order guide table [sc_cat_item_guide] for the onchange of the "requested_for" field.
But there is no field named "requested_for" in the order guide table....