The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the status of a servicecall through web-api

Highlighted
Marcelo Criscuo
Occasional Contributor

Changing the status of a servicecall through web-api

Hi everybody!

I need to change the status of a service call through the web-api. I managed that but I think it's not the right way.

This is what I did: in order to change the status you need to get a IStatusServicecall and pass it as an argument to IServicecall.setStatus() method. I'm using the field "text" to get the IStatusServicecall (as in the code pasted bellow) but I think it's kind of inconsistent due to localization issues. That is, if the application is localized and the text changes this approach will fail.

--- begin code ---
private IStatusServicecall findStatus(String text) {
IStatusServicecallHome sscHome = sdSession.getStatusServicecallHome();
IStatusServicecallWhere sscWhere = sscHome.createStatusServicecallWhere();
sscWhere.addCriteriumOnText(text);

IStatusServicecall[] ssc = sscHome.findStatusServicecall(sscWhere);

if (ssc != null)
return ssc[0];
else
return null;
}
--- end code ---

My question is: is there a better way of finding/getting a IStatusServicecall than using the text field? Maybe a numeric field, like an ID or so. I tried to find something like that but I couldn't.

Thanks in advance.

Marcelo
8 REPLIES
Gyula Matics_1
Honored Contributor

Re: Changing the status of a servicecall through web-api

The best solution really depends on the way you want to use the status information.

If you always connect to the server with the same (integration) acconut, then localisation is not a problem. Just make sure that the account used is always using English.

In a different scneario you can use the ordering to find the status. But the ordering may change if the statuses are changed.

Or you can use the object id, but that may be different on a different server, or if statuse are created or removed.
Marcelo Criscuo
Occasional Contributor

Re: Changing the status of a servicecall through web-api

Thanks for helping Gyula. Your answer has clarified some points.

Something I really miss is a better documentation about the api. The javadocs are very poor. Do you (or somebody else) know such a documentation? Does it exist? I'm always asking myself questions like "What does this Ordering field mean? What does it represent?".

Gyula Matics_1
Honored Contributor

Re: Changing the status of a servicecall through web-api

There is no better documentation that I know of.

On the other hand I think that the API follows the structure and logic of the service desk GUI very closely. So it helps a lot if you know the application and java GUI very well.
Jeff Kays
Frequent Visitor

Re: Changing the status of a servicecall through web-api

Marcelo - this is the same mechanism we use to find objects like statuses, priorities, services, etc. As Gyula pointed out, you can use other attributes like the OID or ordering, but we've run into problems with ordering changing. We also run our code on both a test and production system so the OIDs may not match, so we've decided using the name of the object is the key we will use. We try to keep the keys defined as properties so if they were ever to change we would only need to change the property file rather than change code and recompile.

Besides the API, there is the Web API Programmer's Guide. It should have been on your SD CD, but you can also get it online. Go to:
http://ovweb.external.hp.com/lpe/doc_serv/

Then pick Service Desk, the version you're running and OS. At that point you should be able to grab the document.

Also, when using getText, some object home interfaces have a "searchOnText" method that you can use. This saves you from having to create the where object and populating it.

jeff
Marcelo Criscuo
Occasional Contributor

Re: Changing the status of a servicecall through web-api

Thanks for your hints, I'll remember them when I am programming.

Actually, I already know the Programmer's Guide, I was wondering if there was any other document. But that's ok, now I know there is not.

Jeff, could you please paste here a little example of using the object's name for searching?

Thanks for your help.
Marcelo
Jeff Kays
Frequent Visitor

Re: Changing the status of a servicecall through web-api

My previous response wasn't clear, when I said name I meant the value stored in the "text" attribute. We use the same logic for finding a status, priority, etc, as you show above by using the text attribute. To me, this is the "common name" that our users know the object by. So while there are risks to using the text attribute as your key (such as someone changing it), in our environment it worked out better than other attributes such as the OID or ordering. We have a very small group of power users that can change names on items like statuses, priorities, etc.

Hopefully that's a bit clearer...

jeff
Marcelo Criscuo
Occasional Contributor

Re: Changing the status of a servicecall through web-api

I'm sorry for the confusion. Now I understand.

Thanks Jeff and Gyula for your helpful answers.

Considering the information you've provided I concluded that using the text field will be better.
Faisal Javed
Regular Collector

Re: Changing the status of a servicecall through web-api

Is this code can be used to change the HP QC defect status through API? If yes, then can you help me step by step as I have no knowledge about this.

Thanks
//Add this to "OnDomLoad" event