- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 07:20 AM
Hi all,
in the normal view of a service catalog item, if you were to try executing g_form.getParameter("sysparm_item_guid") you would get the cart item id in advance before the item gets submitted.
Is there a way where i can get the cart item id of the item getting submitted in service portal?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 10:59 PM
Ahh, yes now I understand.
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.
Maybe you can describe your business logic for this, and I might be able to give you some alternative suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2018 10:59 PM
Ahh, yes now I understand.
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.
Maybe you can describe your business logic for this, and I might be able to give you some alternative suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2018 09:58 AM
Hi Lars,
Thanks for your reply and confirming it is not feasible. I did have a back up solution for my problem though i preferred the cleaner approach of using the cart item id as that was more reliable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2019 08:25 AM
Could you share your workaround for this?
I'm having a similar issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2019 10:52 AM
We were struggling with this also.
We wanted to check to see if the user had added an attachment, and then use that information in an onChange catalog client script.
We are on London and using the Service Portal for our Service Catalog.
As discussed above in this thread, it seems there is no way to determine the sys_id of the associated sc_cart_item from g_form when using Service Portal.
We came up with the below 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 as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2020 11:55 PM
Can you share the full code of this Widget and how you use it.