CA Service Management

  • 1.  how to get ci item details using doQuery?

    Posted Oct 18, 2016 06:02 AM

    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>();

    cmdbCiIds.add("0BDEBDAEB6665749963C2EE91ED65B16");

    cmdbCiIds.add("B89E4CEC1030654C93626D0D9B9D462E");

    // 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.



  • 2.  Re: how to get ci item details using doQuery?

    Broadcom Employee
    Posted Oct 18, 2016 06:39 AM

    Hey Balakrishna,

     

    I think its your id clause that's causing the error:

     

    Try something like:  id in (U'07126F5917350547B5375B44A72495AC', U'C7EE6AB28F60CD4592E38D08A516CBCA')

     

    _R



  • 3.  Re: how to get ci item details using doQuery?

    Posted Oct 18, 2016 07:26 AM

    Hi Raghu,

     

    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.



  • 4.  Re: how to get ci item details using doQuery?

    Broadcom Employee
    Posted Oct 18, 2016 07:40 AM

    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?

     

    _R



  • 5.  Re: how to get ci item details using doQuery?

    Posted Oct 18, 2016 09:50 AM

    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 (";

    for(i=0;i<arrayIDs.length();i++)

    {

       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.