The CreatorCon Call for Content is officially open! Get started here.

How to pass a custom field value in Catalog Checkout(sc-checkout) widget into the corresponding request.?

Amritha1
Tera Guru

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. 

find_real_file.png

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

10 REPLIES 10

Kit Cheong
Giga Guru

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();