RangerMSP Ticket – Open Count

For reporting or work flow management, knowing how many tickets are open currently or historically by day/week/month/year is important for managing a IT MSP business. In the RangerMSP GUI there is an “Open Date” and a “Close Date” field. However these fields are not available via the RangerMSP API and therefore not available via Jupiter Server.

The RangerMSP data fields that we have access to are listed here.
http://www.rangermsp.com/wiki/CSharp_API#Ticket_Class

Therefore our only option currently available is to on a regular automated basis query Jupiter Server for a list of tickets and store that data for offline processing

The key field to query on is the Status field

* Status FLDTKTSTATUS    The Ticket Status(optional).
* Possible values:
* New = 100
* Pending = 200
* Scheduled = 300
* In - House Service = 400
* On - Site Service = 500
* Laboratory Service = 600
* Hold = 700
* Other = 800
* Cancelled = 900
* Completed = 1000

You can see from the above table that codes less than or equal to 800 are open tickets. To obtain all open tickets for a specific RangerMSP account we use a Select statement with two criteria. One criteria selects based on the AccountREC_ID for the Account of interest, and the second criteria selects based on the Status field having a value of 800 or less.

Select statement to select open tickets for a single Account. Note that we are limiting the number of results to 40. This Select statement is written using C# and assumes a variable name called AccountREC_ID that contains the REC_ID of the Account to retrieve open tickets for

Select selectTicket = new Select
            {
                Link = "and",
                RecordLimit = 40,
                Criterias = new Criteria[2]
                {
                    new Criteria
                    {
                        Field = "AccountREC_ID",
                        Operation = "opEqual",
                        Value = AccountREC_ID
                    },
                    new Criteria
                    {
                        Field = "Status",
                        Operation = "opLessThanOrEqual",
                        Value = “800”
                    }
                }
            };
To make life easier if all you want is a count of the tickets, rather than a list, we have written an additional RangerMSP API Method in Jupiter Server called GetOpenTicketCount.
In the example below the AccountREC_ID of an account that you would like is passed in to get the number of OpenTickets for. But you could use it with a difference Select statement to get all OpenTickets matching a different search criteria.
Here is some C# code showing how to use GetTicketOpenCount in a C# client application that you could write.
Using the above status values, a Open Ticket has a Status value less or equal to 800.
#region GetOpenTicketCount
        public static void GetOpenTicketCount(string accountRecId, out bool success, out int count)
        {
            success = false;
            count = 0;

            try
            {
                Select select = new Select
                {
                    Link = "and",
                    RecordLimit = 1,
                    Criterias = new Criteria[1]
                    {
                        new Criteria
                        {
                            Field = "AccountREC_ID",
                            Operation = "opEqual",
                            Value = accountRecId
                        }
                    }
                };

                count = RangerMSPClient.GetTicketOpenCount(select);
            }
            catch (Exception e)
            {
                Global.GenericException(e);
            }

            success = true;
        }
#endregion