How to provide a name on requests in Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2021 02:49 PM
I am in need of a way to allow our users to provide a name for their cart when they are checking out. Currently when the 'My Requests' list is viewed it is impossible to determine the details of the request by looking at the list alone. Each item needs to be clicked to determine what the exact request is.
We have several customers that place requests for event setups and having a list just show "LV Event Setup' is not useful. I would like to allow them to provide a name for the request so that the list then shows something like "Mandalay Bay Event 3/23".
Current list shows:
I would like it to show something like the below, where the values in the box were provided by the user when the request was submitted.
- Labels:
-
Request Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2021 03:45 PM
Do you want to do this for all items or just certain ones? If just certain items, do they have their own dedicated workflows? Do you have two step checkout enabled?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2021 03:56 PM
I would ideally like to provide it as an option for all items setup with two-set checkout; which is the majority of our items.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2021 05:12 PM
Hi Cassandra,
Thanks for confirming. You do have an option but it does require cloning the OOB widgets (as they're read only) to make the necessary modifications.
Clone widget "Catalog Checkout" -
Update HTML to:
<div id="sc_cat_checkout" ng-class="{'panel panel-default': !c.isNative}" sn-atf-blacklist="IS_SERVICE_CATALOG">
<h1 class="padder-md h3" ng-if="!c.isNative">{{::checkoutPopupTitle}}
<span class="text-base">
<i class="fa fa-close pull-right text-base" autofocus="true" tabindex="0" ng-click="c.cancel()"
aria-label="Close modal"></i>
</span>
</h1>
<div class="wrapper-md clearfix b-t">
<div class="form-group">
<div class="row">
<div class="col-sm-8" ng-class="{'m-t-xl': c.isNative}">
<label for="requested-for" ng-class="{'m-l': c.isNative}">${Request For}
</label>
<i ng-if="!c.isNative" class="fa fa-info-circle"
uib-tooltip="${Request for yourself or on behalf of another person}" tooltip-placement="right"
tooltip-append-to-body="true" tabindex="0" tooltip-trigger="mouseenter focus" role="tooltip"
aria-label="${Request for yourself or on behalf of another person}"></i>
<sn-record-picker id="requested-for" field="c.requestedFor" table="'sys_user'"
display-field="c.data.reqForDispCol" display-fields="c.data.reqForDispCols"
value-field="'sys_id'" search-fields="c.data.reqForSearchCols"
default-query="c.data.reqForQuery" page-size="100" options="{allowClear : false}"
sn-disabled="!c.data.disable_req_for">
</sn-record-picker>
</div>
<div class="padder-v col-sm-12" ng-if="c.allowDeliveryAddress()" ng-class="{'m-t-xl': c.isNative}">
<label for="deliver-to" ng-click="c.showDeliveryAddr = !c.showDeliveryAddr" tabindex="0"
aria-expanded="{{c.showDeliveryAddr}}" ng-class="{'m-l': c.isNative}">${Delivery Information}
<span class="text-muted"> ${(Optional)}</span>
<i ng-if="::!c.isNative"
ng-class="c.showDeliveryAddr ? 'fa fa-minus-square-o' : 'fa fa-plus-square-o'"
class="m-t-xs pull-left accordion-toggle"></i>
</label>
<textarea class="form-control" ng-if="c.isNative || c.showDeliveryAddr" ng-model="c.deliverTo"
id="deliver-to" ng-model-options="{ updateOn: 'blur' }" ng-change="c.changeShippingInfo()"
rows="3"></textarea>
</div>
<div class="col-sm-12" ng-class="{'padder-v': !c.allowDeliveryAddress()}"
ng-class="{'m-t-xl': c.isNative}">
<label for="special-instructions" ng-click="c.showSpecialInstructions = !c.showSpecialInstructions"
tabindex="0" aria-expanded="{{c.showSpecialInstructions}}"
ng-class="{'m-l': c.isNative}">${Special Instructions} <span class="text-muted">
${(Optional)}</span>
<i ng-if="::!c.isNative"
ng-class="c.showSpecialInstructions ? 'fa fa-minus-square-o' : 'fa fa-plus-square-o'"
class="m-t-xs pull-left accordion-toggle"></i>
</label>
<textarea class="form-control" ng-if="c.isNative || c.showSpecialInstructions"
ng-model="c.special_instructions" id="special-instructions"
ng-model-options="{ updateOn: 'blur' }" ng-change="c.changeShippingInfo()" rows="3"></textarea>
</div>
<!--Added customisation to allow customers to set custom request short_description -->
<div class="col-sm-12" ng-class="{'m-t-xl': c.isNative}">
<label for="request-short-description" ng-click="c.showRequestShortDescription = !c.showRequestShortDescription"
tabindex="0" aria-expanded="{{c.showRequestShortDescription}}"
ng-class="{'m-l': c.isNative}">${Request Short Description} <span class="text-muted">
${(Optional)}</span>
<i ng-if="::!c.isNative"
ng-class="c.showRequestShortDescription ? 'fa fa-minus-square-o' : 'fa fa-plus-square-o'"
class="m-t-xs pull-left accordion-toggle"></i>
</label>
<textarea class="form-control" ng-if="c.isNative || c.showRequestShortDescription"
ng-model="c.request_short_description" id="request-short-description"
ng-model-options="{ updateOn: 'blur' }" ng-change="c.changeRequestShortDescription()" rows="3"></textarea>
</div>
<!----------------------------------------------------------------------------------->
</div>
</div>
</div>
<div ng-if="c.isNative">
<div class="attachment-list" ng-if="c.data.action !== 'order_now'">
<now-attachments-list template="sp_attachment_single_line" class="padder-b"></now-attachments-list>
</div>
<div ng-class="{'flex-center attachment-height': c.isNative}">
<label ng-if="c.data.action !== 'order_now'" style="font-weight:normal;cursor:pointer;"
class="padding-top-s">
<span style="padding-left:28px;">${Add attachments}</span>
<sp-attachment-button></sp-attachment-button>
</label>
</div>
</div>
<div class="panel-footer clearfix" ng-if="!c.isNative">
<div class="attachment-list" ng-if="c.data.action !== 'order_now'">
<now-attachments-list template="sp_attachment_single_line" class="padder-b"></now-attachments-list>
</div>
<div>
<label ng-if="c.data.action !== 'order_now'" style="font-weight:normal;cursor:pointer;"
class="padding-top-s">
<sp-attachment-button></sp-attachment-button>
<span style="padding-left:4px;">${Add attachments}</span>
</label>
<div class="pull-right">
<button name="cancel" ng-disabled="c.checkoutInProgress" ng-click="c.cancel()"
class="btn btn-default">${Cancel}</button>
<button ng-disabled="c.checkoutInProgress || !c.requestedFor.value" name="submit"
ng-click="c.triggerCheckout()" sn-focus="true" class="btn sc-btn btn-primary m-l-xs">
<span ng-show="!c.checkoutInProgress">{{::checkOutMsg}}</span>
<span ng-show="c.checkoutInProgress">{{::m.checkingOutMsg}}</span>
</button>
</div>
</div>
</div>
</div>
Update Client Script:
function($scope, $http, $timeout, $location, spScUtil, nowAttachmentHandler, spUtil, $log, spAriaUtil, $q, spAtf, spModal, spAriaFocusManager, cabrillo, snAnalytics) {
var c = this;
c.showSpecialInstructions = false;
c.showRequestShortDescription = false;
c.showDeliveryAddr = false;
c.isNative = cabrillo.isNative() && c.data.isMEE;
c.updateDetails = function() {
c.deliverTo = c.data.cart.delivery_address;
c.special_instructions = c.data.cart.special_instructions;
c.requestedFor = {
displayValue: c.data.cart.requested_for_display_name,
value: c.data.cart.requested_for,
name: 'requested_for'
};
}
spAtf.init().then(function(atf) {
$scope._atf = atf;
atf.expose('checkout_util', checkoutUtil);
});
var checkoutUtil = {
checkout: function() {
var defer = $q.defer();
$scope.c.triggerCheckout();
var cleanUp;
var isOrderGuide = c.data.action == 'order_guide';
if(isOrderGuide)
cleanUp = $scope.$on('$sp.sc_order_guide.submitted', function(o, result) {
$timeout(function() {
cleanUp();
defer.resolve(result);
}, 10);
});
else
cleanUp = $scope.$on('$sp.sc_cat_item.submitted', function(o, result) {
$timeout(function() {
cleanUp();
defer.resolve(result);
}, 10);
});
return defer.promise;
}
}
$scope.$on('dialog.upload_too_large.show', function(e){
$log.error($scope.m.largeAttachmentMsg);
spUtil.addErrorMessage($scope.m.largeAttachmentMsg);
});
$scope.m = $scope.data.msgs;
$scope.checkOutMsg = $scope.m.checkOutMsg;
$scope.checkoutPopupTitle = $scope.m.checkoutPopupTitle;
displayNativeButtons();
var ah = $scope.attachmentHandler = new nowAttachmentHandler(function (attachments, action) {
$scope.attachments = attachments;
if (action === "added")
$scope.setFocusToAttachment();
if (action === "renamed")
spAriaUtil.sendLiveMessage($scope.m.renameSuccessMsg);
if (action === "deleted")
spAriaUtil.sendLiveMessage($scope.m.deleteSuccessMsg);
spUtil.get($scope, {action: "from_attachment"});
}, function (error) {
spUtil.addErrorMessage(error.msg + error.fileName);
});
ah.setParams('sc_cart', c.data.cart.sys_id, 1024 * 1024 * $scope.data.maxAttachmentSize);
$scope.attachmentHandler.getAttachmentList();
$scope.confirmDeleteAttachment = function(attachment) {
if (c.isNative) {
if (confirm($scope.data.msgs.delete_attachment)) {
$scope.attachmentHandler.deleteAttachment(attachment);
$scope.setFocusToAttachmentButton();
}
} else {
spModal.confirm($scope.data.msgs.delete_attachment).then(function() {
$scope.attachmentHandler.deleteAttachment(attachment);
$scope.setFocusToAttachmentButton();
});
}
}
c.changeShippingInfo = function() {
if (c.data.action !== 'order_now')
c.server.get({
action: "change_shipping_info",
requestedFor: c.requestedFor.value,
special_instructions: c.special_instructions,
deliverTo: c.deliverTo,
cart: {name: c.data.cart.name}
}).then(function(response) {
c.data.cart = response.data.cart;
c.updateDetails();
});
}
c.triggerCheckout = function() {
var newURL;
c.checkoutInProgress = true;
putCheckingOutBtn();
var webAnalyticsMsgSuffix = c.isNative ? " - NOW Mobile" : "";
var additionalParms = {'sysparm_requested_for': c.requestedFor.value,
'special_instructions': c.special_instructions,
'delivery_address': c.deliverTo
};
if (c.data.parentParams) {
additionalParms.sysparm_parent_sys_id = c.data.parentParams.sysparm_parent_sys_id;
additionalParms.sysparm_parent_table = c.data.parentParams.sysparm_parent_table;
}
additionalParms.engagement_channel = c.data.engagement_channel;
additionalParms.referrer = c.data.referrer;
if (c.data.action == 'order_now') {
spScUtil.orderNow(c.data.item.sys_id, c.data.item.quantity, c.data.item.fields, c.data.item.newRecordID, additionalParms).then(function(response) {
$scope.server.get({
action: 'log_request',
itemDetails: {
sys_id: $scope.data.item.sys_id,
name: $scope.data.item.name,
sys_class_name: $scope.data.item.sys_class_name
}
});
//Added to perform request update once item is ordered.
$scope.server.get({
action: 'update_request',
itemDetails: {
"request_id" : response.data.result.request_id,
"short_description" : c.request_short_description,
"table" : response.data.result.table
}
});
var a = response.data.result;
if (!$scope.data.parentParams)
$scope.$emit("$$uiNotification", a.$$uiNotification);
$scope.$emit("$sp.sc_cat_item.submitted", a);
// build and send payload for instrumentation
var payload= {};
payload.name = "Submit Catalog Request";
payload.data = {};
payload.data["Catalog Title"] = c.data.item.title;
payload.data["Catalog SysID"] = c.data.item.sys_id;
payload.data["Shopping Cart"] = "false";
snAnalytics.addEvent(payload);
if (c.options.auto_redirect == 'false') {
$rootScope.$broadcast("$sp.service_catalog.cart.submitted", true);
spUtil.addInfoMessage($scope.m.requestSubmitted);
return;
} else if (!$scope._atf) {
removeCabrilloButtons();
newURL = $location.search('id=sc_request&is_new_order=true&table=sc_request&sys_id=' + a.sys_id);
spAriaFocusManager.navigateToLink(newURL.url());
}
}, function(response) {
c.cancel();
if (response.data.result && response.data.result.errMsg)
spUtil.addErrorMessage(response.data.result.errMsg);
});
} else if (c.data.action == 'order_now_wishlisted_item') {
spScUtil.orderWishlistedItem(c.data.item.sys_id, c.data.item.quantity, c.data.item.fields, c.data.item.newRecordID, additionalParms).then(function(response) {
$scope.server.get({
action: 'log_request',
itemDetails: {
sys_id: $scope.data.item.sys_id,
name: $scope.data.item.name,
sys_class_name: $scope.data.item.sys_class_name
}
});
var a = response.data.result;
if (!$scope.data.parentParams)
$scope.$emit("$$uiNotification", a.$$uiNotification);
$scope.$emit("$sp.sc_cat_item.submitted", a);
$rootScope.$broadcast("$sp.service_catalog.wishlist.update");
if (c.options.auto_redirect == 'false') {
$rootScope.$broadcast("$sp.service_catalog.cart.submitted", true);
spUtil.addInfoMessage($scope.m.requestSubmitted);
return;
} else {
newURL = $location.search('id=sc_request&is_new_order=true&table=sc_request&sys_id=' + a.sys_id);
spAriaFocusManager.navigateToLink(newURL.url());
}
});
}
else {
c.data.delivery_address = c.deliverTo;
c.data.special_instructions = c.special_instructions;
c.data.requested_for = c.requestedFor.value;
var isOrderGuide = c.data.action == 'order_guide';
c.server.update().then(function(response) {
if (!response.result)
return;
// build and send payload for instrumentation
var cartData = c.data.cartData;
var cartDataLen = c.data.cartData.length;
for (var i = 0; i < cartDataLen; i++) {
var payload= {};
payload.name = "Submit Catalog Request";
payload.data = {};
payload.data["Catalog Title"] = cartData[i].title;
payload.data["Catalog SysID"] = cartData[i].sys_id;
payload.data["Catalog Cart SysID"] = cartData[i].cartID;
payload.data["Shopping Cart"] = "true";
snAnalytics.addEvent(payload);
}
c.data.action = null;
if (isOrderGuide) {
window.GlideWebAnalytics.trackEvent("Service Catalog", "Order Guide Request" + webAnalyticsMsgSuffix, "Catalog Request Submitted", $scope.data.item.items.length, 0);
$scope.$emit("$sp.sc_order_guide.submitted", $scope.data.result);
}
else {
window.GlideWebAnalytics.trackEvent("Service Catalog", "Catalog Cart" + webAnalyticsMsgSuffix, "Catalog Request Submitted", c.data.numberOfCartItems, 0);
$scope.$emit("$sp.cart.submitted", $scope.data.result);
}
if (c.options.auto_redirect == 'false') {
$rootScope.$broadcast("$sp.service_catalog.cart.update");
$rootScope.$broadcast("$sp.service_catalog.cart.submitted", true);
spUtil.addInfoMessage($scope.m.requestSubmitted);
return;
}
else {
if ($scope.data.result.sys_id)
newURL = $location.search('id=sc_request&is_new_order=true&table=sc_request&sys_id=' + $scope.data.result.sys_id);
else
newURL = $location.search('id=requests&is_new_order=true');
removeCabrilloButtons();
spAriaFocusManager.navigateToLink(newURL.url());
$timeout(function(){
$rootScope.$broadcast("$sp.service_catalog.cart.update", {checkedOut: true});
$rootScope.$broadcast("$sp.service_catalog.cart.submitted", true);
})
}
});
}
}
$scope.$on("field.change", function(evt, parms) {
if (parms.field.name == 'requested_for') {
c.data.cart.requested_for = parms.newValue;
var getShippingAddrURL = '/api/sn_sc/v1/servicecatalog/cart/delivery_address/' + parms.newValue;
$http.get(getShippingAddrURL).then(function handleSuccess(response) {
if (response.data.result) {
c.deliverTo = response.data.result.trim();
} else {
c.deliverTo = '';
}
c.changeShippingInfo();
});
}
});
c.cancel = function() {
if (c.isNative) {
cabrillo.viewLayout.setTitle(c.oldTitle);
removeCabrilloButtons();
}
$rootScope.$broadcast("$sp.service_catalog.cart.cancel_order", true);
}
c.allowDeliveryAddress = function () {
if (c.data.item)
return c.data.item.request_method != "request"
return true;
}
var mespClosePopupUnregister = $rootScope.$on("mesp.popup.close", function() {
// Timeout is to give a better user experience otherwise when this popup opens,
// the cabrillo buttons will be displayed immediately giving a bad user experience.
$timeout(function(){
displayNativeButtons();
});
});
var mespOpenPopupUnregister = $rootScope.$on("mesp.popup.open", function() {
// Timeout is to give a better user experience otherwise when this popup opens,
// the cabrillo buttons will be displayed immediately giving a bad user experience.
$timeout(function(){
removeCabrilloButtons();
});
});
$scope.$on("$destroy", function() {
mespClosePopupUnregister();
mespOpenPopupUnregister();
});
function removeCabrilloButtons() {
if (c.isNative)
cabrillo.viewLayout.setBottomButtons();
}
function displayNativeButtons() {
if (c.isNative) {
if (typeof cabrillo.viewLayout.getTitle == 'function') {
cabrillo.viewLayout.getTitle().then(function(title) {
c.oldTitle = title;
cabrillo.viewLayout.setTitle($scope.checkoutPopupTitle);
});
}
var buttons = [
{
title: $scope.m.dialogCancel,
enabled: true,
backgroundColor: '#f7f7f7',
textColor: '#000000'
},
{
title: $scope.checkOutMsg,
enabled: true,
backgroundColor: $scope.data.sys_properties.mobileNativeColor,
textColor: '#FFFFFF'
}
];
cabrillo.viewLayout.hideBackButton();
cabrillo.viewLayout.setNavigationBarButtons();
cabrillo.viewLayout.setBottomButtons(buttons, function(buttonIndex) {
if (buttonIndex == 0) {
c.cancel();
}
else {
c.triggerCheckout();
}
});
}
}
function putCheckingOutBtn() {
if (c.isNative) {
var buttons = [
{
title: $scope.m.dialogCancel,
enabled: false,
backgroundColor: '#f7f7f7',
textColor: '#000000'
},
{
title: $scope.m.checkingOutMsg,
enabled: false,
backgroundColor: $scope.data.sys_properties.mobileNativeColor,
textColor: '#FFFFFF'
}
];
cabrillo.viewLayout.setBottomButtons(buttons, function(buttonIndex) {});
}
}
c.updateDetails();
}
Update Server Script:
(function() {
var localInput = input; //to safeguard pullution of "input" via BR or other scripts
data.engagement_channel = options.native_mobile ? 'mobile' : (options.isServiceWorkspace ? 'workspace' : 'sp');
data.referrer = options.referrer;
data.action = options.action;
if (data.action)
data.item = options.item;
else
data.action = 'checkout';
if (localInput && localInput.action == "from_attachment")
return;
else if (localInput && localInput.action === 'log_request') {
$sp.logStat('Order Now Request', localInput.itemDetails.sys_class_name, localInput.itemDetails.sys_id, localInput.itemDetails.name, $sp.getPortalRecord().getUniqueValue());
$sp.logStat('Cat Item Request', localInput.itemDetails.sys_class_name, localInput.itemDetails.sys_id, localInput.itemDetails.name, $sp.getPortalRecord().getUniqueValue());
return ;
}
if (localInput && localInput.action == "update_request"){
var scRequestGR = new GlideRecord('sc_request');
if(scRequestGR.get(localInput.itemDetails.request_id)){
scRequestGR.setValue('short_description' , localInput.itemDetails.short_description)
scRequestGR.update();
}
}
var cartName = '';
if (localInput)
cartName = localInput.cart.name;
else if (options.cart)
cartName = options.cart.name;
addInstrumentationData();
var m = data.msgs = {};
m.dialogTitle = gs.getMessage("Delete Attachment");
m.dialogMessage = gs.getMessage("Are you sure?");
m.dialogOK = gs.getMessage("OK");
m.dialogCancel = gs.getMessage("Cancel");
m.renameSuccessMsg = gs.getMessage("Attachment renamed successfully");
m.deleteSuccessMsg = gs.getMessage("Attachment deleted successfully");
m.delete_attachment = gs.getMessage("Delete Attachment?");
m.requestSubmitted = gs.getMessage("Thank you, your request has been submitted.");
m.checkingOutMsg = gs.getMessage("Submitting...");
if (data.item.request_method == "request") {
m.checkOutMsg = gs.getMessage("Request");
m.checkoutPopupTitle = gs.getMessage("Request Confirmation");
} else {
m.checkOutMsg = gs.getMessage("Checkout");
m.checkoutPopupTitle = gs.getMessage("Order Confirmation");
}
data.isMEE = options.native_mobile == 'true';
data.sys_properties = {
mobileNativeColor: gs.getProperty("glide.sc.mobile.primary_color", "#1f8476")
};
data.maxAttachmentSize = parseInt(gs.getProperty("com.glide.attachment.max_size", 1024));
if (isNaN(data.maxAttachmentSize))
data.maxAttachmentSize = 24;
m.largeAttachmentMsg = gs.getMessage("Attached files must be smaller than {0} - please try again", "" + data.maxAttachmentSize + "MB");
var cartJS;
if (data.action !== 'order_now') {
cartJS = new sn_sc.CartJS(cartName, '' + gs.getUser().getID());
if (localInput && localInput.action === "change_shipping_info") {
cartJS.setSpecialInstructions(localInput.special_instructions);
cartJS.setRequestedFor(localInput.requestedFor);
cartJS.setDeliveryAddress(localInput.deliverTo);
}
}
if (localInput && localInput.action == 'order_guide') {
var guideJS = new sn_sc.OrderGuide('' + cartName);
cartJS = new sn_sc.CartJS('' + cartName);
for(var i = 0; i < localInput.item.items.length; i++) {
guideJS.navigateFromMap(localInput.item.items[i]);
}
cartJS.activateGuide();
cartJS.setRequestedFor(localInput.requested_for);
cartJS.setDeliveryAddress(localInput.delivery_address);
cartJS.setSpecialInstructions(localInput.special_instructions);
cartJS.setParentParams(localInput.parentParams);
cartJS.setEngagementChannel(localInput.engagement_channel);
cartJS.setReferrer(localInput.referrer);
var request = cartJS.checkoutGuide();
data.result = {sys_id: request.request_id, number: request.request_number, table: 'sc_request'};
var portalId = $sp.getPortalRecord().getUniqueValue();
$sp.logStat('Order Now Request', localInput.item.sys_class_name, localInput.item.sys_id, localInput.item.name, portalId);
$sp.logStat('Cat Item Request', localInput.item.sys_class_name, localInput.item.sys_id, localInput.item.name, portalId);
return;
}
if (localInput && localInput.action === 'checkout') {
cartJS.setEngagementChannel(localInput.engagement_channel);
checkoutCart(cartJS);
return;
}
if (data.action !== 'order_now')
data.cart = cartJS.getCartDetails(false);
else {
var requested_for = {
user_id : gs.getUser().getID(),
user_name: gs.getUser().getDisplayName()
};
data.cart = {
name: cartName,
sys_id: gs.generateGUID(),
requested_for: requested_for.user_id,
requested_for_display_name: requested_for.user_name,
delivery_address: sn_sc.CartJS.getRequestedForAddress(requested_for.user_id)
};
}
if (options && options.parentParams) { //if parent is passed
data.parentParams = options.parentParams;
}
if (options && options.requested_for && options.requested_for.id) { //If Passed via options
data.cart.requested_for = options.requested_for.id;
data.cart.requested_for_display_name = options.requested_for.displayValue;
data.cart.delivery_address = sn_sc.CartJS.getRequestedForAddress(options.requested_for.id);
}
if (data.request_for) { //if value is changed by user
var user = GlideUser.getUserByID(data.request_for);
if (user.exists()) {
data.cart.requested_for = data.request_for;
data.cart.requested_for_display_name = user.getDisplayName();
data.cart.delivery_address = sn_sc.CartJS.getRequestedForAddress(data.request_for);
}
}
data.disable_req_for = sn_sc.CartJS.canViewRF();
setRequestedForCols(data);
data.reqForQuery = gs.getProperty("glide.sc.request_for.query");
})();
function setRequestedForCols(data) {
var reqForDispCols = gs.getProperty("glide.sc.request_for.columns");
if (JSUtil.notNil(reqForDispCols)) {
data.reqForDispCol = "name";
data.reqForDispCols = reqForDispCols.replace(/;/g, ",");
data.reqForSearchCols = data.reqForDispCol + "," + data.reqForDispCols;
}
else {
var displayCol = GlideTableDescriptor.get("sys_user").getDisplayName();
data.reqForDispCol = displayCol || "name";
data.reqForSearchCols = data.reqForDispCol;
var refAcCols = GlideTableDescriptor.get("sys_user").getED().getAttribute("ref_ac_columns");
if(JSUtil.notNil(refAcCols))
data.reqForDispCols = (refAcCols + "").replace(/;/g, ",");
var refAcSearch = GlideTableDescriptor.get("sys_user").getED().getAttribute("ref_ac_columns_search");
if(JSUtil.notNil(data.reqForDispCols) && JSUtil.notNil(refAcSearch) && refAcSearch == "true")
data.reqForSearchCols += "," + data.reqForDispCols;
}
}
function checkoutCart(cart) {
try {
var cartItemGr = cart.getCartItems();
data.numberOfCartItems = cartItemGr.getRowCount();
var requestedCatItems = new global.GlobalServiceCatalogUtil().findCatItemsForSpLogs(cartItemGr);
var request = cart.checkoutCart(true);
data.result = {
sys_id: request.request_id,
number: request.request_number,
table: 'sc_request'
};
var portalId = $sp.getPortalRecord().getUniqueValue();
$sp.logStat('Checkout Request', 'sc_request', request.request_id, request.request_number, portalId);
new global.GlobalServiceCatalogUtil().logRequestedCatItems(requestedCatItems, portalId);
} catch(e) {
var catalogExceptionUtils = new CatalogExceptionUtils();
if(catalogExceptionUtils.isCartException(e))
gs.addErrorMessage(e.getMessage());
data.numberOfCartItems = 0;
}
}
function addInstrumentationData() {
if (input && input.action == 'change_shipping_info')
return;
if (data.action == 'order_now') {
var catSysId = data.item.sys_id;
var gr = new GlideRecord('sc_cat_item');
if (gr.get(catSysId))
data.item.title = gr.getValue('name');
} else if (input && input.cart && data.action == 'checkout') {
var cartData = [];
var _data;
var cartSysId = input.cart.sys_id;
var grCart = new GlideRecord('sc_cart_item');
grCart.query("cart", cartSysId);
while(grCart.next()){
_data = {};
var gr2 = new GlideRecord('sc_cat_item');
if (gr2.get(grCart.getValue("cat_item"))) {
_data.sys_id = gr2.getValue('sys_id');
_data.title = gr2.getValue('name');
_data.cartID = cartSysId;
cartData.push(_data);
}
}
data.cartData = cartData;
}
}
You'll also need to modify the "SC Catalog Item" [widget-sc-cat-item-v2] server script with any references to "sc-checkout" to the ID you gave the above widget upon copying it. You'll then need to update your sc_cat_item page to contain your new SC Catalog Item widget.
That might sound scary but it's not too bad!
Outcome will be the following:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2021 07:52 AM
Thank you, I will look into these updates. This update though seems to change the short description but it would not change what the users see in their list of 'My Tickets' in the Service Portal. Would you possible have a suggestion on how to update that list?
Currently it shows the name of the item that was first added to the cart. I would like the users to see a distinct name they provide, if they opt to provide it.