how to get ci item details using doQuery?
I have list of id's of ci item and I want to get the details of the ci as shown below.
List<String> cmdbCiIds = new ArrayList<String>();
// Use doQuery() to get a list of all active Requests.
ListResult doQueryResult = new ListResult();
doQueryResult = usd.doQuery(sid, "nr", "id in" + cmdbCiIds);
But when I try this, I'm getting below error.
Error fetching: AHD03053:Bad where clause: Parse error at : "( id in[0BDEBDAEB6665749963C2EE91ED65B16, B89E4CEC1030654C93626D0D9B9D462E] ) AND ( (family.sym !='CIP') AND (family.sym !='SOX Enterprise Family') )" (syntax error)
Can you please suggest me how can I get the details by id.
I think its your id clause that's causing the error:
Try something like: id in (U'07126F5917350547B5375B44A72495AC', U'C7EE6AB28F60CD4592E38D08A516CBCA')
Yes, we can get when we use
doQueryResult = usd.doQuery(sid, "nr", "id in(U'B89E4CEC1030654C93626D0D9B9D462E',U'0BDEBDAEB6665749963C2EE91ED65B16')"); But here l will get list of ids as list from other source. Hence I need to pass that list as it is in where condition. Is this possible.
I believe the only option here is for you to format them to the requirements that SDM whereClause is expecting. Maybe other members can think of some alternatives?
If i understand correctly, your question is more about coding than ServiceDesk.
You can create your "in" statement with a loop, concatening values.
Cheap example #1 :
var whereClause = "id in (";
whereClause += "U'" + arrayIDs(i) + "'";
whereClause += ")";
And, is there a specific reason for you to use doQuery instead of doSelect? If yes, do not forget to delete the list from the server.