P-VI: Update a CSR with Java Web Service Calls

Intended Audience: Technical Users and Administrators of Stat
Intended Subject: Update a CSR via Java Web Service calls
Intended Reaction: Happy Stat Customers
Keywords: Stat, Web Services, Java, CSR, Update Existing CSR


Hello fellow Stat Technical Users & Administrators!

Welcome to a new year and a new series of Blog posts!

 

This series will focus on getting the most out of Stat integration with other systems such as updating an existing CSR within Stat. This could be because the information was updated in another Help Desk System,
or one of our own internal applications.

 

The call to updateCSR() is used to update the typical CSR fields you would see on the Main CSR screen. This would be things like Assigned User, Surprisingly - We would not use this call for anything related to the CSR’s Workflows or CSR Approvals.

 

These calls have their own Web Service specific calls which we will cover in a later Blog post. To update a CSR we will want to call the 3rd routine in the list below which is updateCSR()

What’s the goal of this Post?

The goal of post number four is to enable your technical team to quickly retrieve an existing CSR’s through a Web Service call.

Examples of this may be:

  • When a ticket gets updated in another system such as Service Now, HP Quality Center, Remedy or another Help Desk System you may want to have it updated automatically within Stat or vise-versa.
  • When an associated CSR within Stat, such as belonging to the same Project, is updated, or closed, we may want to update or close the associated CSR.

Caution & User Reference:

If you have not worked with Stat Web Services in the past, this is not the place to begin. You’ll need to setup your environment and ensure other settings are verified.

If you are not familiar with Stat Web Services, please refer to “Appendix G: Stat Web Services” in the Stat System Administrators Guide.

You can also find sample code and further documentation on the Stat Installation CD. On the CD you will see a directory called “web_services_sample“.

In this directory is a PDF on Stat Web Services along with a Zip file called StatWS.zip The zip file contains the sample code and additional instructions on setting up your environment and running the samples included.

 

Let’s Go!

For this specific post we will look at retrieving an existing CSR.

Updating an existing CSR:

To update a CSR we need to make the following Web Service call: updateCSR ()

For this, I’m using the same Java Source/Class file named = StatWSCSRCalls.java, and StatWSCSRCalls.class respectively.

In the StatWSCSRCalls class there are two calls available to me:

/* StatWSCSRCalls CSR Attachment Related Calls:

1 = saveNewCSR(long connectId, CSRType csr, List<AttachmentType> attachments)

2 = retrieveCSR(long connectId, String sdcd, long csrId)

3 = updateCSR(long connectId, String sdcd, long csrId)

4 = getCSRTemplateValues(long connectId, String sdcd)

5 = getApplicationDescriptionTemplate(long connectId, String sdcd, String appcode)

6 = getApplicationResolutionTemplate(long connectId, String sdcd, String appcode)

7 = getCSRTypeDescriptionTemplate(long connectId, String sdcd, String appcode)

8 = getCSRTypeResolutionTemplate(long connectId, String sdcd, String appcode)

*/


Remembering that we need to first establish a connection to the Stat Web Service as part of the process, we will pass in our User Id and Password along with the call to make.

For the test environment that would be: %JAXWS_RUN_COMMAND% StatWSCSRCalls %HOSTNAME% %WSPORT% %USERID% %PASSWORD% %CALL_2_RUN%

My actual call is %JAXWS_RUN_COMMAND% StatWSCSRCalls WIN-52C9JR1VJH7 8080 MyUserID MyPassword 3

Here’s a screenshot of the Java call running:


 

Let’s see the results within Stat:

In this call – We will update several values on the CSR:

CSR FIELD VALUE:

FROM VALUE:

TO VALUE:

Customer ID:

Tannenbaum, John (Cust_ID #9)

Franklin, Benny (Cust_ID #6) *3

Short Descr:

CSR From Blog P-IV CSR Create

Updated CSR for Part VI Blog.

Customer Priority Code:

Emergency (WCRT)

High (Crit)

Application Code:

HRMS Core (HRMSC)

HRMS Benefits (HRBNT)

CSR Priority Code:

Critical (CRIT)

Medium (MED)

Assigned Queue:

Functional Owners (FuncOwners)

Managers (Managers)

 

 

Before the update call we can look at the CSR within Stat and grab a screenshot of it to use as a comparison after we make the call.

 

After the update call we can look at the output and ensure it is what we expected by comparing the output to the above screenshot.

 

Now let’s see what’s happening in the code:

We will use the CSRType bean again for this call along with the AttachmentType we used in the previous blog posts.

Here’s the CSRType Bean:

// --------------------------------------------------------------

Begin CSRType Bean/Class:

<xsd:complexType name="CSRType">

<xsd:sequence>

<xsd:element name="sdcd" type="xsd:string" />

<xsd:element name="csrId" type="xsd:long" />

<xsd:element name="applicationCode" type="xsd:string" />

<xsd:element name="environmentCode" type="xsd:string" />

<xsd:element name="customerId" type="xsd:string" />

<xsd:element name="csrTypeCode" type="xsd:string" />

<xsd:element name="workflowId" type="xsd:string" />

<xsd:element name="statusCode" type="xsd:string" />

<xsd:element name="queueId" type="xsd:string" />

<xsd:element name="assignedToId" type="xsd:string" />

<xsd:element name="priorityCode" type="xsd:string" />

<xsd:element name="openedById" type="xsd:string" />

<xsd:element name="title" type="xsd:string" />

<xsd:element name="openDate" type="xsd:dateTime" />

<xsd:element name="dueDate" type="xsd:dateTime" />

<xsd:element name="closeDate" type="xsd:dateTime" />

<xsd:element name="description" type="xsd:string" />

<xsd:element name="textDescription" type="xsd:string" />

<xsd:element name="resolution" type="xsd:string" />

<xsd:element name="textResolution" type="xsd:string" />

<xsd:element name="projectCode" type="xsd:string" />

<xsd:element name="customerPriorityCode" type="xsd:string" />

<xsd:element name="trackingNumber" type="xsd:string" />

<xsd:element name="altNumber" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

// End CSR Type Bean/Class
// --------------------------------------------------------------

Here’s the call: *1, *2

%JAXWS_RUN_COMMAND% StatWSCSRCalls WIN-52C9JR1VJH7 8080 MyUserID MyPassword 3

 

public static void main(String[] args) throws Exception {

 

... Set variables, make connection, and the like...

 

case 3: // Do updateCSR:

System.out.println(" ");

System.out.println("Call #" + calltorun + ": updateCSR...");

System.out.println(" ");

// ===================================================================================

// 3 = CSRType updateCSR(long connectId, String sdcd, long csrId)

// This method retrieves a list of active Customers.

// Input Parameters:

// connectId - A valid connect Id obtained by calling WSLoginService.connect.

// sdcd - Service Domain Code.

// csrId - CSR Id

// Return Parameter:

// A CSRType representing the retrieved CSR Field Values.

// ===================================================================================

try {

// --------------------------------------------------------------------------------------

// Update the CSRType with the proper CSR Data: Hardcoded for Blog Space & Readability.

// Blog Post Note: Bolded values below = Our CSR update values.

// Blog Post Note: Required Values listed below are required always; even if you do not change them.

// --------------------------------------------------------------------------------------

CSRType csr = new CSRType(); // Below = Changed/Updated Values.

csr.setSdcd("HRS"); //(Required) Update With Service Domain Code.

csr.setCsrId(133); //(Required) Update With CSR ID Number.

csr.setCustomerId("6"); //(Required) Update With Valid Customer ID #.

csr.setCustomerPriorityCode("HIGH"); //(Optional) Update With Valid Cust Priority Code.

csr.setApplicationCode("HRBNT"); //(Required) Update With Valid Application Code.

// csr.setEnvironmentCode(""); //(Optional) Update With Valid Environ Code or Leave Blank.

// csr.setOpenedById("WRHART"); //(Optional) Update With Valid UserID Code.

// csr.setProjectCode(""); //(Optional) Remove Project Code.

csr.setTitle("Updated CSR for Part VI Blog."); //(Optional) Update CSR Title.

csr.setCsrTypeCode("EMR"); //(Required) Update With Valid CSR Type Code.

csr.setStatusCode("Propd"); //(Required) Update With Valid Status Code.

csr.setPriorityCode("MED"); //(Required) Update With Valid CSR Priority Code.

csr.setWorkflowId("2"); //(Required) Update With Valid Workflow ID.

csr.setQueueId("Managers"); //(Required) Update With Valid Queue ID.

csr.setAssignedToId("WRHART"); //(Required) Update With Valid User ID in Queue.

// csr.setDescription("CSR Update Fmt"); //(Optional) Update With Description Format Code.

// csr.setTextDescription("CSR Update"); //(Optional) Update With Description Text.

// csr.setResolution("Resolution"); //(Optional) Update With Resolution Format

// csr.setTextResolution("Resolution Txt"); //(Optional) Update With Resolution Text.

// csr.setAltNumber("1234"); //(Optional) Update With Alt Phone.

// csr.setTrackingNumber("TRACK-123"); //(Optional) Update With Tracking Number.

 

// ---------------------------------------------------------

csrPort.updateCSR(connectId, csr);

System.out.println("============================================================================");

System.out.println(" Update CSR Data For CSR: " + sdcd + "-" + csr.getCsrId() + " Completed Successfully.");

System.out.println("============================================================================");

} catch(WSCsrFault e) {

WSCsrFaultType ue = e.getFaultInfo();

System.out.println("ERROR: Call = updateCSR. Error = " + ue.getMessage());

return;

}

break;

 

... Remaining Series of Calls and Code Close...

 

} // end switch (calltorun)

System.out.println(" ");

System.out.println("Java Web Service Call Completed Successfully.");

System.out.println(" ");

}

}

 

A Word of Caution:

Be sure to pay attention to the warnings located in each of the call headers. If this CSR was not assigned to me, if the CSR is opened within Stat, or any of the other warning found in the header you will receive an error stating that the CSR could not be updated because the CSR could not be “Locked” for update.

The output will look similar to the below:


 

And that’s it!

With roughly 100 lines of code we set and established a connection to Stat, we then updated the CSR information and received the successfully completed output.

We also took into consideration error control and user feedback/output.

The above code set is not a complete standalone app. With the proper imports, variables, and a few other wrappers, it would still not be more than 100 lines or so.

*1 If you would like a copy of the sample code used here, please see the Documents section of the Stat User Community.

*2 I do not profess to be a pro at Java, but more of a Java noob. Please excuse any blatant coding mishaps.

*3 You can get the Customer ID value from the STAT.CUSTOMERS table as shown below:


In Closing…

In the next post we will move on to another area of Stat Web Services. Stay Tuned! Thank you for taking the time to read this post. I hope you found it informative.

Respectfully,

 

William R. Hart

Solutions Architect

William.Hart@quest.com

Dell | Quest Group, Pre-Sales

Anonymous