display RITM instead of REQ on Service Portal header menu with details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:04 PM
I am needing to display RITM's in my_requests page on the portal instead of REQ however I also required more information as well e.g. short_description (from the variable)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2024 10:11 PM
Hi @Scotty88
1: Identify or Create the Widget
First, identify the widget being used on the my_requests page. If it’s using the out-of-the-box “Requests” widget, consider cloning this widget to avoid modifying the base system widget directly.
2: Modify the Server Script
You’ll need to adjust the server script of your widget to query RITMs (sc_req_item table) instead of REQs (sc_request table). Additionally, you’ll pull in the necessary details such as short_description from the variables associated with each RITM
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 04:29 PM
Hi, can you please show me the steps on how to this do? Not very familar with modifying widgets
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 09:19 PM
Hi @Scotty88
Step 1: Understand the Existing Widget
First, identify the widget used in the My Requests page. The default widget might be “SC Request” or something similar. You can find this by navigating to the page in the Service Portal Designer and clicking on the part of the page that lists the requests. The designer should show you which widget is being used.
Step 2: Clone and Customize the Widget
It’s a best practice to clone an existing widget before making changes, to avoid losing the original functionality and to make it easier to update ServiceNow in the future.
1. Clone the Widget: In the Service Portal Configuration, go to Widgets, find the widget you identified in Step 1, and clone it.
2. Modify the Server Script: In your cloned widget, you’ll need to modify the server script to query RITMs (sc_req_item) instead of REQs (sc_request). Use GlideRecord to query the sc_req_item table for records related to the current user. Include any additional fields you need—like those containing short_description—in your query.
For example
var gr = new GlideRecord(‘sc_req_item’);
gr.addQuery(‘requested_for’, gs.getUserID());
gr.query();
while (gr.next()) {
// Process each RITM, extracting the fields you need, such as short_description from variables
}
3. Access Variables: To access the variables (short_description or others) associated with each RITM, you’ll need to query the sc_item_option_mtom table, which maps variables to catalog items (RITMs). This might involve an additional GlideRecord query within your loop through the RITMs.
A simplified example might look like:
var ritmDesc = new GlideRecord(‘sc_item_option_mtom’);
ritmDesc.addQuery(‘request_item’, gr.getUniqueValue()); // Use the sys_id of the current RITM record
ritmDesc.query();
if (ritmDesc.next()) {
// Now, ritmDesc holds the record that links the RITM to its variables
// You can access the variable values here
}
4. Amend the HTML Template: Adjust the HTML template of your widget to include the additional information you’re pulling from the RITM and variable records.
### Step 3: Update the Service Portal Page
Finally, replace the original widget on the My Requests page with your customized widget. You do this by navigating to the Service Portal Page Editor, selecting the default requests widget, and replacing it with your newly cloned and customized widget.
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma