Custom fields in sc_cart, and copy to sc_request upon checkout
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2017 04:52 PM
Hi,
I'm looking for information on GlideappCart, specifically how I can duplicate the setDeliveryAddress() function for my own custom checkout variable, and then ensure it's copied to the sc_request upon checkout.
Goal:
Add a custom variable to the service portal shopping cart, and have it copy to the Request upon order placement (similar to Delivery Address and Special Instructions fields).
My plan is:
1. Create new fields in both sc_request and sc_cart
2. Modify Service Portal shopping cart widget (and associated ng-template) to include the new form field.
3. Write code to handle the getting/setting of this field to the sc_cart table -- need help
3. Ensure my custom field gets copied from the sc_cart to the sc_request upon order placement -- need help
I've tracked down where these actions gets performed OOB, my notes are below.
- user clicks checkout button,
- which fires c.triggerCheckout() in client script of widget,
- which sends an ajax call to the server script of widget, via c.server.update() with action = "checkout".
- widget server script then saves Special Instructions, Requested For and Delivery address to sc_cart, via functions SPCart.setSpecialInstructions() and similar. SPCart is defined in a script include 'SPCart'. setSpecialInstructions() just that runs the setSpecialInstructions method within cart object created by GlideappCart.getCartforRhino(). I cannot find GlideappCart definition anywhere! So I don't know how to replicate setSpecialInstructions() for my custom field.
- widget server script then runs placeOrder(), which I think is defined in script include 'Cart'. This uses GlideappRequestNew() to make an empty Request (I think) and then copyCart() to create a new Request based on the cart (I think). I cannot find definition for copyCart().
- the request is now placed, and REQ workflow is about to begin (which needs to access my custom variable)
But perhaps I'm making this more complicated than it needs to be. How can I
a) copy the functionality of the setSpecialInstructions() function to save input from widget to the current sc_cart, and
b) get my variable from sc_cart to sc_request when a cart order is placed, BEFORE the Request workflow runs (http://wiki.servicenow.com/index.php?title=Execution_Order_of_Scripts_and_Engines#gsc.tab=0)
Looking forward to any assistance!! Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2018 10:00 AM
Hi Michael,
Did you succeed in adding your functionality ? If so, how did you manage the change ?
I also want to change the behaviour of setSpecialInstructions.