Show delivery time on catalog item in the service portal

Shannon Burns
Kilo Sage

Does anyone know how to modify the widget that shows the details for a catalog item to include the delivery time?   It used to show in the old catalog, but the widget does not display it OOB for the Service Portal.

Thanks,

Shannon

1 ACCEPTED SOLUTION

In case anyone comes across this, I finally found a way to get this on the form.   I used the info from this post


Re: Service Portal - How can I add delivery time to catalog item



But I had to change the one line in the HTML to this to get it to work


<div class="text-muted">${Delivery Time}: {{::data.sc_cat_item.delivery_time}}</div><br/>


View solution in original post

8 REPLIES 8

Nate23
Mega Guru

in sp on that ticket form of the RITM point your mouse over the widget and ctrl+right click and edit widget in the server script there is a line var fields = $sp.getFields(gr, 'number,state,sys_created_on,location'); you will have to add your estimated deliver date field in there. if you widget is oob you will have to clone it. click the hamburger(three lines stacked) next to the save button and click clone this widget


I don't see a line to getFields.   This is the server script:



// populate the 'data' variable with catalog item, variables, and variable view


(function() {


options.show_add_cart_button = (options.show_add_cart_button == "true");



if (options.page) {


var pageGR = new GlideRecord("sp_page");


options.page = (pageGR.get(options.page)) ? pageGR.getValue("id") : null;


}



if (options.table) {


var tableGR = new GlideRecord("sys_db_object");


options.table = (tableGR.get(options.table)) ? tableGR.getValue("name") : null;


}



options.url = options.url || "?id={page}&table={table}&sys_id={sys_id}";


data.showPrices = $sp.showCatalogPrices();


var m = data.msgs = {};


m.submitMsg = gs.getMessage("Submit");


m.submittedMsg = gs.getMessage("Submitted");


m.createdMsg = gs.getMessage("Created");


m.trackMsg = gs.getMessage("track using 'My Items' in the header or on the ITSC home page");


// m.clickMsg = gs.getMessage("click here to view");


m.clickMsg = gs.getMessage("");


m.dialogTitle = gs.getMessage("Delete Attachment");


m.dialogMessage = gs.getMessage("Are you sure?");


m.dialogOK = gs.getMessage("OK");


m.dialogCancel = gs.getMessage("Cancel");


m.largeAttachmentMsg = gs.getMessage("Attached files must be smaller than {0} - please try again", "24MB");



if (input)


data.sys_id = input.sys_id;


else if(options.sys_id)


data.sys_id = options.sys_id;


else


data.sys_id = $sp.getParameter("sys_id") || $sp.getParameter('sl_sys_id');



data._attachmentGUID = gs.generateGUID();


// portal can specify a catalog home page


data.sc_catalog_page = $sp.getDisplayValue("sc_catalog_page") || "sc_home";


var validatedItem = new GlideappCatalogItem.get(data.sys_id);


if (!validatedItem.canView())


return;



data.sc_cat_item = $sp.getCatalogItem(data.sys_id, true);


if (data.sc_cat_item.category) {


var categoryGR = new GlideRecord('sc_category');


categoryGR.get(data.sc_cat_item.category);


data.category = {


name: categoryGR.getDisplayValue('title'),


url: '?id=sc_category&sys_id=' + categoryGR.sys_id


}


}



$sp.logStat('Catalog View', data.sc_cat_item.sys_class_name, data.sys_id, data.sc_cat_item.name);


})()


ahh you are looking at the item before they submit whereas I am looking at it after it has been submitted. so we are looking at two different widgets



find_real_file.png


either way you have to update the widget where you would like it to appear. I would just look at the widget you just posted and the code of the "ticket form" widget that should get you an idea of you can add what you want in there.