How do we update the Requested For in the Order Confirmation Pop Up?

scottneeb
Tera Contributor

As part of the Kingston upgrade it now displays an Order Confirmation dialog after you click Order Now.  The problem we're having is it doesn't pull the Requested For from the catalog item we're ordering, so if the user changes the Requested For it doesn't update the Requested For in the Order Confirmation window.  As you can see in this screenshot they are different.

find_real_file.png

21 REPLIES 21

Hi Peter,

Thanks so much for your guidance and pointing out in using 'console.log(input)'; found the root cause through there.
Below is my code that I used :

var getRequestor = '';
for (var i=0; i<input.items.length; i++) {
	if (input.items[i].variables.hasOwnProperty('requested_for')){
		getRequestor = new GlideRecord('sys_user');
		if(getRequestor.get(input.items[i].variables.requested_for)) {
			options.requested_for_id = getRequestor.sys_id.toString();
			options.requested_for_display = getRequestor.name.toString();
		}
	}
}

Since the Order Guides can have multiple catalog-items, the items are stored as array-items; hence input.items[] returns the desired outcome.

Your code returns the desired requested-for even if the variable is hidden by UI-Policy, which is in a way a better solution that you do not require multiple places to input the data, i.e on each catalog-item as well as the Order Confirmation > Request For field.

Thank you so much once again for your code and the guidance.

Regards,
Samiul


p.s: I am using the updated widget

Ah, nice catch... yeah, that makes sense about the input array

Hi Peter,

Just noticed that the 'location' value linked with the user record does not populate in the 'Delivery Information' textbox. 
If you change the value of 'Request For' within the 'Order Confirmation' popup window, then 'Delivery Information' gets updated with the changed record's location value.


By any chance could you advise how to pass the location value from Catalog Item's "Requested For" variable to "Delivery Information"? I have tried numerous options but not able to find any outcome. 

Also, is it possible to make the 'Delivery Information' textbox mandatory?


Thanks in advance,
Samiul

Hi Samiul,

               I am trying to copy the requested for from the order guide to the popup i am not able to achieve it. i tried using the below code

// added to pick up the requested for field & pass to order now
if(input.itemDetails.fields.hasOwnProperty('requested_for')){
  var getRequestor = new GlideRecord('sys_user');
  if(getRequestor.get(input.itemDetails.fields.requested_for)){
    options.requested_for_id = getRequestor.sys_id.toString();
    options.requested_for_display = getRequestor.name.toString();}
}

with  var embeddedWidgetOptions = ['auto_redirect'];

It worked for single catalog items but it is not working for the order guide.. Tried using your code it didn't work can you please share some inputs that worked for you.

 

TIA

 

 

Thank you Peter!

Your solution worked like a charm for me and solved my problem 🙂