- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
Can someone help me how can I achieve this?
To summarize my request, what they want is use the watchlist functionality in portal view so that the users without access on our backend can view it using the portal.
Then there's this request tab or button beside the user's profile and when you click it there's this dropdown called "VIEW" wherein we can see the open request and closed request that we or user created.
The requirement that they gave to me is that can we add another value on that drop down and we can call it "Closed Watch list", wherein when they select that value all of the closed tickets will be visible as long as they're part of the watch list.
As you can see on the screenshots I provided, I already apply it but under the closed watch list the title of the tickets I'm seeing is just the number of the ticket instead of the short description for incident and name of the catalog items for RITM.
I'll attached as well the default view or title display under the open request.
Thank you in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Itsmehiiiiiiii, Glad that you are able to see the titles correctly.
Yes, you will get the duplicates and for the same I asked to adjust the function getMyRequestSysIds().
Nevertheless, could you please try replacing with below one. You can make any necessary adjustment in the if and else block ( your filter name or any new add query)
function getMyRequestSysIds() {
var ids = {};
var rq_filter = new GlideRecord('request_filter');
rq_filter.addActiveQuery();
if (rq_filter.isValidField('applies_to')){
if (localInput && localInput.view === 'closed_watchlist'){
rq_filter.addQuery('applies_to', 1).addOrCondition('applies_to', 10);
rq_filter.addQuery('title', 'Watched Closed List');
}
else {
rq_filter.addQuery('applies_to', 1).addOrCondition('applies_to', 10);
rq_filter.addQuery('title','!=', 'Watched Closed List');
}
}
rq_filter.query();
while (rq_filter.next()) {
var tableName = rq_filter.table_name;
if (rq_filter.isValidField('table'))
tableName = rq_filter.table;
var gr = new GlideRecord(tableName);
if (!gr.isValid())
continue;
gr.addQuery(rq_filter.filter);
gr.enableSecurityFeature('data_filter');
gr.query();
if (tableName == 'sc_request')
alsoRequest = true;
while (gr.next()) {
var portalSettings = {};
portalSettings.page = rq_filter.portal_page.nil() ? '' : rq_filter.portal_page.getDisplayValue() + '';
portalSettings.primary_display = rq_filter.primary_display.nil() ? '' : rq_filter.primary_display + '';
portalSettings.secondary_displays = rq_filter.secondary_display.nil() ? '' : rq_filter.secondary_display + '';
ids[gr.sys_id + ''] = portalSettings;
}
}
return ids;
}
Please note that I'm sharing above code without any validation, make necessary adjustment, if required.
You can create duplicate titles too in request filter like one for incident and one for Request, but if you wish to keep them different, then change the addQuery() accordingly.
P.S: surely, there might be better ways to filter in/out the Filter Request, but I can write above without any validation right now.
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Sorry not very sure on that and you will have to debug from your side.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Itsmehiiiiiiii , I assume that you are able to fetch right information under Closed Watch List. Since I'm not sure how you have done this customization, an ideal way is to define the My Request Filter ( request_filter table).
If you have done in this way then probably you can verify the 'Secondary fields to display' under the Portal Settings of your new Filter as below.
If you have defined everything in the same way and still you see this problem, then you can share your complete Widget code to understand the gap, if any.
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Nishant8 ,
I'm okay to share the script that I have, please the code below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Itsmehiiiiiiii, Thanks for sharing the server side code. Like as I mentioned, the ideal way would be to create a request filter and OOB functionality takes care of displaying right fields on the portal. However, I notice that you are making your own Watched List in the code and storing in _watched_request_ids in the data object.
I'm wondering whether your watched list filter is displaying the right Requests/INCs, please verify this part once more.
Although, there is no CS and HTML shared, I think you are passing the right input and comparing at the server side, you can make a few modifications as below
- Try to create my request filter as I suggested ( you can refer existing ones )
- stop populating data._watched_request_ids
- as you are already passing localInput.view === 'closed_watchlist', basis on the same you can decide in the following function getMyRequestSysIds() whether to look for watched list or not for e.g. OOB can continue as it is without watched list and for your new code, you can include your filter (surely you can decide somewhere else too, but on the fly I feel this place better)
- keep other checks enabled localInput.view === 'closed_watchlist'
As I'm sharing my thoughts without validating, you might have to make a few adjustment, but this approach is much easier and will allow you to enable/disable functionalities at later stage.
should you need any further assistance, please feel free to respond back, I can try at my end at my free time as you know this might take some time.
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Nishant8 ,
I tried creating a request filter for closed watchlist items, but I noticed it’s also affecting the existing open and closed requests. Records that are part of the watchlist are being included in both the open and closed request lists.
I created the request filter for both Incident and Requested Item and added a condition where the Watchlist contains javascript:gs.getUserID() and the State is Closed.
