How to place Catalog Item on Service Portal Home page

gauthamaron
Mega Contributor

I know we have a page "Sc_cat_item" where we have a "SC Catalog Item" widget which helps in dispalying catalog item and all.but it takes input when we click on any record producer its sys_id and page id. I want to place a specified record producer on home page.

Any leads would be greatly appreciated.

Thanks,

Gautham

1 ACCEPTED SOLUTION

lSurya 24
Giga Guru

Hello Gautham,



First of all clone the SC Catalog Item" widget and place the widget in your home page.



And you need to do slight modifications in the server side script:



find_real_file.png



You have to place your home page id and sys id of the record producer in above lines where I have pointed in screenshot.



Thanks,


Surya Amara



PS: Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

8 REPLIES 8

Hi I tried the same solution but its not working ? please advise

Shihab Ahmed
Tera Contributor

Hi Surya,

 

I have similar requirement with a record producer.

I need to put a record producer in a section of a page.

I tried your solution but its showing error.

find_real_file.png

My server script on cloned widget after update is:

 

(function() {
// portal can specify a catalog and catalog category home page
data.sc_catalog_page = $sp.getDisplayValue("sc_catalog_page") || "sc_home";
data.sc_category_page = $sp.getDisplayValue("sc_category_page") || "sc_category";

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;
}
var page = 'is_nps_survey';
var sys_id='05a1cc75e4c17100ad69e266d72e396a';
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 'Requests' in the header or");
m.clickMsg = gs.getMessage("click here to view");
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");
m.renameSuccessMsg = gs.getMessage("Attachment renamed successfully");
m.deleteSuccessMsg = gs.getMessage("Attachment deleted successfully");

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');

if (!data.sys_id)
return;

data._attachmentGUID = gs.generateGUID();
var validatedItem = new sn_sc.CatItem('' + data.sys_id);
if (!validatedItem.canView())
return;

data.sc_cat_item = $sp.getCatalogItem(data.sys_id, true);
if (data.sc_cat_item.category) {
var categoryJS = new sn_sc.CatCategory(data.sc_cat_item.category);
data.category = {
name: categoryJS.getTitle(),
url: '?id='+data.sc_category_page+'&sys_id=' + data.sc_cat_item.category
}
}

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

 

--------------------------

 

Am I doing something incorrectly? Please let me know.

 

Thanks

Shihab

I am having the same issue.  Did you resolve this or get any additional feedback?

SamuelTse
Tera Guru

Thanks for the solution. I couldn't get it to work based on your instruction. I need to modify one more line of code to get it to work:

change this:

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

to:

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

 

this did the trick for me. I can see the form now, but I have yet try the form and see if it submits correctly. I thought this would help.

 

Sam