Add view control to My Request Widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 06:03 PM
Hi,
I have a requirement to add the ability to toggle from card view and list view on the My Request widget. Any tips?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 02:08 AM
Sure, here are the steps you can follow to add the ability to toggle between card view and list view on the My Request widget:
1. Open the widget instance that you want to modify in Service Portal.
2. In the Widget Instance form, click on the Widget field to open the widget record.
3. In the Widget form, click on the "Clone" button to create a copy of the widget. This is to ensure that you don't modify the out-of-the-box widget.
4. In the cloned widget, navigate to the HTML Template field. This is where you will add the code to add the toggle button.
5. Add a button or a switch in the HTML Template to serve as the toggle. You can use AngularJS or Bootstrap to create the toggle. Here is a sample code for a simple button:
html
Toggle View
6. In the Client Script field, add a function to handle the toggle. Here is a sample code:
javascript
c.toggleView = function() {
c.data.listView = !c.data.listView;
}
7. In the Server Script field, add a line to initialize the listView variable. Here is a sample code:
javascript
data.listView = true;
8. Now, modify the HTML Template to display the requests in card view or list view based on the listView variable. You can use the ng-show or ng-hide directives to conditionally display the elements. Here is a sample code:
html
9. Save the changes and test the widget in Service Portal.
Please note that this is a simplified example and you might need to adjust the code based on your exact requirements and the structure of the My Request widget.
nowKB.com
For a good and optimistic result, and solving ServiceNow-related issues please visit this website.https://nowkb.com/home
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 05:39 AM
Hi, none of the code snippets came through.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 02:16 AM
Hi
The code is here, please check and try to add as you need.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 05:37 AM
I will reference this widget. I referenced the topics widget but this one looks more simple. thanks