How to pass a custom field value in Catalog Checkout(sc-checkout) widget into the corresponding request.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 04:57 AM
Hi Community,
I want to pass a custom field value while checking out my cart. That value should be saved in my request in the sc_request table.
I have already copied the catalog checkout (sc_checkout) widget. As seen in the screenshot below, I added an additional field to the widget (Manager), and also added a field to request table in which the value from the widet will be stored.
How do I map the manager field from widget to my request table? I would want it to work in the same was as the "delivery Information" and "Special Instructions" is mapped to the request.
Widget: Catalog checkout (sc_checkout)
Thanks,
Amritha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2021 02:04 AM
Steps to modify the Service Portal > Cart > Proceed to Checkout.
You'll need to modify other code/clone widgets to cover off the other 'Proceed to Checkout' and 'Order Now' buttons.
Tested on a Rome OOTB instance.
Step 1
Add the custom field to the sc_request table.
Step 2
Clone the widget 'SC Shopping Cart'
In the HTML add
<div class="col-sm-12">
<label for="cost_centre">Cost centre:</label>
<textarea ng-model="c.data.cost_centre" id="cost_centre"></textarea>
</div>
In the server script function getCartCheckoutModal change
embeddedWidgetId: 'sc-checkout'
to something like
embeddedWidgetId: 'sc-checkout-v2'
Add the widget to the sc_cart portal page.
Step 3
Clone the widget 'Catalog Checkout' and set the id to 'sc-checkout-v2'.
In the server script function checkoutCart, after 'var request = cart.checkoutCart(true)' add:
var req = new GlideRecord('sc_request');
if (req.get(request.request_id.toString())) {
req.[your custom field name] = input.cost_centre;
req.update();