order guide back button breaking order guide

patricklatella
Mega Sage

Hi all,

we've discovered an issue with an order guide, where if the user clicks the back button in the guide (see screen shot) to navigate back to the "Describe needs" page, and then navigates again forward "Choose Options">"Checkout"...it breaks the cart.   So in the 2nd screen shot you see that the item "New Hire Login Accounts" is there on the "Choose Options" page, but then when you get back to Checkout...it's gone.   Anyone know if this is a known problem with the cart?   Or is there a configuration setting we need to do?   thanks!

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

patricklatella
Mega Sage

I think I fixed my script...added an "if" to check if a field is empty and if not, then don't clear the cart, and if it's empty...clear the cart.



function onLoad() {


if(g_form.getValue('emp_workday_id')!=''){


return;


}else{


 


    var ga = new GlideAjax('CartUtil');


  ga.addParam('sysparm_name', 'clearCart');


  ga.getXMLWait();


}


}


View solution in original post

2 REPLIES 2

patricklatella
Mega Sage

I believe I've found what's causing this error.   I have an onLoad client script in place to clear the contents of the order guide when the order guide is first opened...this is in place so that if a user abandons an order guide in mid process for whatever reason, when they return to the order guide the cart is empty and they can start fresh...otherwise the items from their unfinished (i.e. not checked out) order guide will show in the cart and would have to be removed.



However the script is acting on the order guide when the back button (both the browser and the order guide's own back button, highlighted in my screen shot in my previous post) are used.   Is there a way to alter my script so that it doesn't do this?   Or at least a way to make the script not fire if the order guide's own back button is used?



Here's the script:



function onLoad() {


    //Type appropriate comment here, and begin script below


    var ga = new GlideAjax('CartUtil');


  ga.addParam('sysparm_name', 'clearCart');


  ga.getXMLWait();


}




and again this is the "Order guide back button" I'm talking about



find_real_file.png


patricklatella
Mega Sage

I think I fixed my script...added an "if" to check if a field is empty and if not, then don't clear the cart, and if it's empty...clear the cart.



function onLoad() {


if(g_form.getValue('emp_workday_id')!=''){


return;


}else{


 


    var ga = new GlideAjax('CartUtil');


  ga.addParam('sysparm_name', 'clearCart');


  ga.getXMLWait();


}


}