How to add request icon and favourite icon in ESC portal on manually created widget

Shashank_sj10
Tera Contributor

We have manually created a widget to display the most recent catalog items. We would like to add the request and favorite icons as in  the out-of-the-box "Recommended for You" widget into our custom widget. How can we achieve that functionality.

 

Attaching screenshot for the reference.

Thanks for any help!

 

 

1 ACCEPTED SOLUTION

Juhi Poddar
Kilo Patron

Hello @Shashank_sj10 

 

You can look for fa icons to add it in this way. 

 

<span class="fa icon fa-heart" ng-class="data.favoriteIcon"></span>

//to add colour
span.fa.icon.fa-heart {
    color: red;
}

 

Please refer the link and look for the desired bootstrap icon.

 

"If you found my answer helpful, please like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"

Thank You
Juhi Poddar

 

View solution in original post

7 REPLIES 7

Hello @Shashank_sj10 

Good to hear that answer helped you!

Now to add the favourite widget to a custom widget

  1. Get the sys_id of catalog item -> server script

 

data.itemSysId = $sp.getParameter('sys_id')

 

This will fetch the sys_id from url

  • Add the favourite widget in custom widget

 

<div>
  <!-- Your custom widget code here -->
  
  <!-- Include the favorite widget, pass sys_id of catalog item -->
  <sp-widget widget="favorite" options="{ 'sys_id': itemSysId }"></sp-widget>
</div>

 

Note: The custom favourite widget will contain the functionality to add the catalog in favourite page. 

Additionally I would suggest to clone the ootb widget if similar functionality is required and then customize it. This is reduce the development time. Refer ootb widget 'ec_favorite'.

 

"If you found my answer helpful, please like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

 

 

 

Thanks for the quick response. I tried this but its not working as expected we are not able to see the favorite icon on the UI of the widget.

 

Can you brief more about the process it would be helpful 

Ravi Kumar A
ServiceNow Employee
ServiceNow Employee

You may find this section of product documentation helpful:
Configure favorites: Explains how to configure favorites and other related information.