- 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
11-22-2023 07:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
So, I have code that can work on the pages without editing the Widget
It works fine for items in the portal and there is the existing "desktop" code you can call using the same function name.
My new problem, Workspace. None works -arghh
function onLoad() {
}
// this function has changed. Originally it was using the parentScope.$parent options when written on a fresh PDI
// on a client that instantly failed. Not sure what version of the Cart Widgets they are using, but removing the $parent
// works.
// if this fails at another customer, do some checking and work out where the scope is located and adapt here as necessary
getCartAttachmentID = function () {
try {
debugger;
var refID = getIDFromScope('top', false) || '';
if (refID == '') {
refID = getIDFromScope('parent', false) || '';
}
if (refID == '') {
refID = getIDFromScope('window', false) || '';
}
if (refID == '') {
refID = getIDFromScope('top', true) || '';
}
if (refID == '') {
refID = getIDFromScope('parent', true) || '';
}
if (refID == '') {
refID = getIDFromScope('window', true) || '';
}
if (refID == '') {
console.error('getCartAttachmentID : scope : Unable to retrieve Cart ID : error : no data retrieved');
}
return refID;
} catch (e) {
console.error('getCartAttachmentID : scope : Unable to retrieve Cart ID : error : ' + e.message);
}
}
getIDFromScope = function (strParent, bolParent) {
try {
bolParent = bolParent || false;
var parentScope;
if (strParent == 'top') {
parentScope = top.window.angular.element('#sc_cat_item').scope();
} else if (strParent == 'parent') {
parentScope = parent.window.angular.element('#sc_cat_item').scope();
} else {
parentScope = window.angular.element('#sc_cat_item').scope();
}
if (bolParent) {
return parentScope.$parent.c.data.sc_cat_item._attachmentGUID || '';
} else {
return parentScope.c.data.sc_cat_item._attachmentGUID || '';
}
} catch (e) {
return;
}
}
