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
10-02-2020 01:42 PM
I haven't utilized this myself, but looking at the OOTB widget, line 97 in the server script has:
cartJS.setParentParams(localInput.parentParams);
You might be able to utilize that method to pass information to the parent (which in service catalog usually refers to the REQ).
If you can use that method, that is probably the best way to accomplish the ask. If not, you can add code to the "checkoutCart" function in that same server script (line 173 OOTB) to update the request record via GlideRecord. You have the table (sc_request) and the sys_id (request.request_id, line 180 OOTB), so you could update the REQ record just like you would any other record via server script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2020 10:17 PM
Thanks, Justin
But unable to do it. Can you please give me demo so that it can make me understand.
It will really help me.
Thanks,
Amritha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 06:56 AM
What exactly aren't you able to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2020 08:23 AM
I tried the below code (Line 75-90 OOTB Catalog Checkout widget, Newyork Version). I tried to hard-code a value to the field. Really not sure if this is the way to accomplish my requirement though.
if (localInput && localInput.action === 'checkout') {
var conflictingCartDomain = cartJS.findConflictingDomain();
if (conflictingCartDomain) {
gs.addErrorMessage(gs.getMessage("Your cart has item(s) belonging to the '{0}' domain. Please change the domain to continue with the checkout.", conflictingCartDomain));
return;
}
var restrictedItems = cartJS.findUserCriteriaRestrictedItems();
if (restrictedItems.length > 0) {
gs.addErrorMessage(gs.getMessage("Your cart has item(s) no longer available. Please remove {0} from cart to continue with checkout.", restrictedItems.join(", ")));
return;
}
var request = cartJS.checkoutCart(true);
// I added my code here.
var record = new GlideRecord('sc_request');
record.addQuery('sys_id', 'request.request_id');
record.query();
gs.log("inside glide")
if (record.next()) {
record.setValue('u_manager_2', "Test");
record.update();
}
//
data.result = {sys_id: request.request_id, number: request.request_number, table: 'sc_request'};
$sp.logStat('Checkout Request', 'sc_request', request.request_id, $sp.getPortalRecord().getUniqueValue());
return;
}