- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 08:55 PM
Hi All,
We are customizing the virtual agent topic for displaying the count of incident. So we have to get incidents which are updated additional comments within last 3days only. For this I tried one code but it fetching all the active incidents of caller but, I need incidents which are updated additional comments field within last 3days.
Code: This is oob script action utility code
Output: getting all the active incidents of caller
regards,
Pavan.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2024 10:07 AM - edited 04-28-2024 10:11 AM
@Pavan Kumar28 I tried to replicate your issue on the Incident table,
ServiceNow does not allow filtering on journal fields directly from the list view. This is because journal fields are not stored in the same table as the record they are associated with. Instead, they are stored in a separate journal table (sys_journal_field), and each entry in a journal field is a separate record in this table.
Used a scripted filter to achieve the above use case,
1. Created a script include which holds the sys id of the incident as "Element ID"
2. Create a filter which pushes the incidents records accordingly on the list view.
Navigate to System Definition -> Filters -> Create New
For testing purpose, I have updated the filter and it considered "Updated on as Today", change your filter accordingly. In the below screenshot it, lists only the record which got updated today.
3. In Virtual agent, in the script action update as below,
Note: Encoded query line colon,
(function execute() {
// Setting the incident count
var incidents = new GlideAggregate('incident');
incidents.addEncodedQuery('sys_id=javascript: new GetUpdatedIncs().getIncidents()^sys_updated_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
//incidents.addQuery('active', true);
//incidents.addQuery('caller_id', vaInputs.user);
incidents.addAggregate('COUNT');
incidents.query();
var incidentCount = 0;
if(incidents.next())
incidentCount = incidents.getAggregate('COUNT');
vaVars.incident_count = incidentCount;
})()
Results : "Displays 2 recently updated incidents" (text has been modified)
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2024 04:35 AM
Hello @Sujatha V M,
I just modified the script as you suggested but, no luck getting same message "You have no active incidents". Could you pls help on this. Attaching the code output as snip.
Script Action code in virtual agent topic:
Output:
Thanks and regards,
Pavan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2024 07:26 AM
As per the condition kindly make sure you have an incident updated today.
Its a simple flow created for the use case with existing code that needs to be added to your topic.
I had updated an incident today where the caller field should the logged in user name.
Reference script was from the topic : Check IT Ticket Status.
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 03:33 AM
Hi @Sujatha V M ,
Thanks for your support, I just modified my output. Now it's working as expected.
Regards,
Pavan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 09:56 PM
@Pavan Kumar28 Appreciate your efforts towards fixing it! Glad to help!
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.