Order Guide - 'Requested For' in the Checkout
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2016 10:48 AM
I've just created an Order Guide with a 'Requested For' Field in the initial tab.
I would like the "Requested for" field in the 'Checkout' tab to auto-fill with the 'Requested For' field from the initial tab. Right now it puts the name of the person who opens the request, which I don't want.
Please advise on how to change that.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2016 02:34 PM
Hi Sarah,
var CartAjaxClientUtils = Class.create();
CartAjaxClientUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRequestedForValue : function() {
var cart_item_id;
var cart_id = this.getParameter("sysparm_cart_id")
var gr = new GlideRecord("sc_cart_item");
gr.addQuery("cart.sys_id", cart_id )
gr.query();
while(gr.next() ) {
cart_item_id = gr.item;
}
var itemGR = new GlideRecord("sc_item_option");
itemGR.addQuery("Question", "Requested For");
itemGR.addQuery("cart_item", cart_item_id);
itemGR.query();
while(itemGR.next()) {
return itemGR.value;
}
},
type: "CartAjaxClientUtils"
});
Then an onload client script for sc_cart table which calls the above utils and submits the value
for getting the sysparm_cart_id you can use gel('sysparm_item_guid').value and for setting the requested for you can use $('sc_cart.requested_for').value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2016 03:17 PM
Thank you!
I'm sorry I am new to this, so I was wondering what I should select as the table and should the type be onload?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2016 03:30 PM
Hi Sarah,
No issues. You can select sc_cart as table and type would be onload.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2016 03:48 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2016 04:21 PM
Hi Sarah,
No the above script you have pasted is not an onload client script. It is a script include.
Create a script include named CartAjaxClientUtils with client callable check box checked.
- var CartAjaxClientUtils = Class.create();
- CartAjaxClientUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
- getRequestedForValue : function() {
- var cart_item_id;
- var cart_id = this.getParameter("sysparm_cart_id")
- var gr = new GlideRecord("sc_cart_item");
- gr.addQuery("cart.sys_id", cart_id )
- gr.query();
- while(gr.next() ) {
- cart_item_id = gr.item;
- }
- var itemGR = new GlideRecord("sc_item_option");
- itemGR.addQuery("Question", "Requested For");
- itemGR.addQuery("cart_item", cart_item_id);
- itemGR.query();
- while(itemGR.next()) {
- return itemGR.value;
- }
- },
- type: "CartAjaxClientUtils"
- });
Then seperately create a client script with type onload and on table sc_cart say with name setRequestedForFromCatalogItem
function onLoad() {
var cart_id = $('sysparm_item_guid').value;
var cartAjaxUtil = new GlideAjax('CartAjaxClientUtils');
cartAjaxUtil.addParam('sysparm_name', 'getRequestedForValue');
cartAjaxUtil.addParam('sysparm_cart_id', cart_id);
cartAjaxUtil.getXML(fillRequestedFor);function fillRequestedFor(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
$('sc_cart.requested_for').value = answer;
}
}
Hope that helps.