How to get cart ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 12:47 AM
I have a catalog item in portal where the user has to upload a csv file into ootb attachment section. Currently I face an issue with cart id which is needed to get the attachment record, in portal I cannot get cart id. I need the attachment in order to check existence, proper naming and type (.csv) of attachment.
Who has an idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 01:01 AM
Hi
Unfortunately it is not possible in serviceportal. The serviceportal uses the cart API and therefore does not pre-generate any IDs as it just passes the catalog item details along when you add an item to the cart.
Here is the workaround:
1. Customize "SC Catalog Item" widget's client script to include "g_form.generatedItemGUID = $scope.data._generatedItemGUID;":
var g_form;
$scope.$on('spModel.gForm.initialized', function(e, gFormInstance){
if (gFormInstance.getSysId() != -1 && gFormInstance.getSysId() != c.getItemId())
return;
g_form = gFormInstance;
$timeout(function() {
$rootScope.$emit('spModel.gForm.rendered', g_form);
}, 175);
// This runs after all onSubmit scripts have executed
g_form.$private.events.on('submitted', function(){
if ($scope.data.sc_cat_item.item_action === "order")
getOne();
else if ($scope.data.sc_cat_item.item_action === "add_to_cart")
addToCart();
else if ($scope.data.sc_cat_item.item_action == "update_cart")
updateCart();
});
//2019-03-04 James McWhinney
g_form.generatedItemGUID = $scope.data._generatedItemGUID;
});
2. Use g_form.generatedItemGUID in your catalog client script.
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2022 12:24 PM
Hi
Glad to see my answer helped you, Kindly mark the answer as Correct & Helpful both such that others can get help.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2023 07:15 AM