How to display RITM info to Service Portal Cart?

Bob20
Tera Contributor

I'm trying to modify the Service Portal cart to show the Short Description on SP Cart (both large and small views). I have made a clone of the Cart widget and the cart template, however I can't seem to find the information I need to edit the widget to show on the RITM Short Description in the cart view. Currently the OOTB view is like this:

Cart.PNG

What I'm hoping to achieve to has it look like this:

New Capture.PNG

I had look through various Community posts and thought that this might work...

{{::data.sc_cat_item.short_description}}   -   However it does not return any data. I'm clearly missing something.

The "Design request: Rack Cards for Rec Centre Promotion" in the example is just a hack, but is the actual Short Description of the RITM. I know that the Widget loops through the items in the cart and populates the page table with the data it pulls from the RITM for things like cost. We do not   use cost/qty in our case and that has already been removed.

Might anyone be able to provide clear direction on this?

Thanks.

Bob.

14 REPLIES 14

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Bob, there isn't a "short description" on the cart that I am aware of.   I just looked at the sc_cart and sc_cart_item tables and there isn't a description field.   Typically when you submit a cart, the request and requested items get created and the short descriptions of those are set via workflow or other means and don't come from the cart itself.


Michael,



If that's the case can I access variables from the form submission? I have a var called u_mr_job_name that would identify the item ion the cart.



Why do I need this? Imaging a user who has put 10 items in the cart, the wishes to go back and edit one of the items, the list in that cart only show the name of catalog Item and does not indicate which is which. We could have one user request 10 items of the same catalog item.




Like your were ordering boxes, the catalog item is a box, an option is color, but now you have 10 boxes in the cart, but which one is the green one? You'd have to go through them all to find it. I should be able to show the color info in the cart (BOX: Green).



Bob.


Allen Andreas
Administrator
Administrator

Hi,



Since you've cloned the widget, you've done part 1, so next would be to look at the server script and see if you can spot the entry that shows what is currently there. It looks like some sort of description, but not a short description of their RITM. Are you sure that's the appropriate place to edit out and place the short description there?



Can you paste the code from the server script here?



Thanks!



Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Allen,



The post by Michael above has some relevance. The Short Description may not have been defined. If that's the case, then do you know if I can access variables from the form submission? In any case, this is the server code:



Bob.



(function() {
var m = data.msgs = {};
m.createdMsg = gs.getMessage("Created");
m.trackMsg = gs.getMessage("track using 'Requests' in the header or");
m.clickMsg = gs.getMessage("click here to view");
var userID = gs.getUser().getID();
var cart = new SPCart(input.cartName, userID);


if (input && input.action === "edit_item") {
  data.editVariablesModal = $sp.getWidget('widget-modal', {embeddedWidgetId: 'sp-variable-editor', embeddedWidgetOptions: {sys_id: input.itemID, table: "sc_cart_item", isOrdering: true}});
  return;
}


if (input && input.action === "update_quantity") {
  var cartItemGR = new GlideRecord("sc_cart_item");
  if (cartItemGR.get(input.itemID)) {
    cartItemGR.setValue("quantity", input.quantity);
    cartItemGR.update();
  }
}


if (input && input.action === "checkout") {
  cart.setSpecialInstructions(input.additionalDetails);
  cart.setRequestedFor(input.cart.requested_for);
  cart.setDeliveryAddress(input.deliverTo);
  var request = cart.placeOrder();
  data.requestData = {
    number: request.getValue("number"),
    table: request.getTableName(),
    sys_id: request.getUniqueValue()
  }
  cart.setSpecialInstructions("");
  cart.setRequestedFor(userID);
  cart.setDeliveryAddress("");
}


if (input && input.action === "remove_item") {
  var itemGR = new GlideRecord('sc_cart_item');
  if (itemGR.get(input.removeItemID))
    itemGR.deleteRecord();
}


if (input && input.action === "save_cart") {
  var newCart = new SPCart(input.newCartName, userID);
  newCart.loadCart(cart.getCartID());
}


data.sys_properties = {
  twostep_checkout: gs.getProperty("glide.sc.checkout.twostep", "false") == 'true'
};


var cartID = cart.getCartID();
data.saveCartModal = $sp.getWidget('widget-modal', {embeddedWidgetId: 'sc_save_bundle', embeddedWidgetOptions: {}});


data.cart = cart.getCartObj();
data.cartItems = cart.getItems();


})();