Need Help in Check Ticket status Topic Virtual Agent

Aparna Gurav
Tera Contributor

Hello Team,

I need assistance with the "Check Ticket Status" topic. Currently, I can only see requested items and incidents that I have raised. However, my requirement is to view both requests raised by the user as well as requests raised for the user.

 

(function execute() {
    /*
        Determining whether there are,
        1. Active incidents opened by the current user
        2. Active Requested items requested for the current user
        and assigning the corresponding script variables.
    */

    // Setting the incident count
    var incidents = new GlideAggregate('incident');
    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;

    // Setting the requested items count
    var reqItems = new GlideAggregate('sc_req_item');
    reqItems.addQuery('active', true);
    reqItems.addQuery('request.requested_for', vaInputs.user);
    reqItems.addAggregate('COUNT');
    reqItems.query();
    var reqItemsCount = 0;
    if (reqItems.next())
        reqItemsCount = reqItems.getAggregate('COUNT');

    vaVars.requested_item_count = reqItemsCount;
})()

 

 

1 REPLY 1

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Did you write the script yourself or is this an extract where work needs be done on though you don't know what/how?

 

My first thought would be, create the filter you are after on a list and copy the breadcrumb and apply that in a query. Perhaps you only need to make it more dynamic.

For example read:

- 2019-09-04 - Article - Utilizing the breadcrumb on lists to generate your query

 

Is that enough input for you? Or more help needed? Please do be specific in the help you need.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn