Jump to content
Sign in to follow this  
Anitha

How to retrieve attachemnt id and attachment name details of an INCIDENT using web services?

Recommended Posts

We are using CA Service desk USD_R11 web services to retrieve INCIDENT details. As part of of our implementation we need to show list of attachments attached to an INC while displaying INCIDENT data. We are unable to find out which web service method will provide attachment details with respect to an INCIDENT. Please assist on this.

Share this post


Link to post
Share on other sites

The linkage between an Incident/Problem/Request and an Attachment is held in the lrel_attachments_requests Object (usp_lrel_attachments_requests table).

You can use a doSelect to query that object and related attmnt object(s) using dotted notation in your attributes parameter.

Share this post


Link to post
Share on other sites

Can we get the attachment id and file name details of an INCIDENT in one call? I am doing two calls to web service to get the Attachment Details (file name, repository details etc). First call to get the attachment id's of an INC and Sec call is to get the attachment details based on attachment ID.

ListResult lstResult = client.doQuery(Convert.ToInt32(sid), "lrel_attachments_requests", "cr = 'cr:403697'");

ListResult lstResult = client.doQuery(Convert.ToInt32(sid), "attmnt", "id=3576309");

Share this post


Link to post
Share on other sites

In order to get the results in one call, you need to use 'doSelect' instead of 'doQuery', 'doQuery' returns a list of Handles (to be queried further), but 'doSelect' returns a list of objects (with attributes) directly.

Share this post


Link to post
Share on other sites

Mitu, even though if we use doSelect(), lrel_attachments_requests object will return only attachment ID and not the attachment name, file path (etc) right. To get the these details again we need to do one more call to get the details based on attachment Id received in first call.

In previous comment I have mentioned two diff objects in doQuery() method.

So can we get these details from only one object?

Edited by Anitha

Share this post


Link to post
Share on other sites

If you're using doSelect, check the 'attributes' parameter after you make the call, see the example in the docs for doSelect.

Share this post


Link to post
Share on other sites

Please look at the syntax for the doSelect method. One of the parameters you can pass is a string array of the attributes you want to retrieve. If you pass an empty array the method will return all the value-based attributes of the object. By using dotted notation, you can retrieve related object attributes. So, along with the attributes from the lrel_attachments_requests record you want, include array values such as:

attmnt.file_name

attmnt.attmnt_name

attmnt.description

Share this post


Link to post
Share on other sites

I need to retrieve a list of all attachments for a given REQUEST #.  doSelect appear as the way to go - yet I cannot figure out how to use it.  Here is an example in Powershell

 

 $fileXML =  $client.doSelect($SID, "attmnt", "id=$ticketNum", 250, "file_name");


Any help will be greatly appreciated.

Edited by markvii
removed unnecessary code

Share this post


Link to post
Share on other sites

hi,

you have incorrect search criteria (id = $ticketNum).

try: 

requests.cr = '$crPersid'

(persid is a ticket's identifier which looks like cr:<1234>)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...