Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Sam Kaveh
    .Net Incident search - RN May 09
    Topic posted September 6, 2010 by Sam Kaveh, last edited October 29, 2011 
    1417 Views, 9 Comments
    Title:
    .Net Incident search - RN May 09
    Content:

    Hi!

    I am looking for a .Net C# code sample mirroring what you can achieve through the XML API through the following:

    "

    <connector>
      <function name="search">
       <parameter name="args" type="pair">
          <pair name="search_args" type="pair">
             <pair name="search_field1" type="pair">
                 <pair name="name" type="string">Contact Last Name</pair>
                 <pair name="compare_val">Johnson</pair>
             </pair>

             <pair name="search_field2" type="pair">
                 <pair name="name" type="string">Post Code</pair>
                 <pair name="compare_val">XX00 0XX</pair>
             </pair>

          </pair>
        </parameter>
        <parameter name="max_rows">10</parameter>
        <parameter name="ac_id">100005</parameter>

      </function>
    </connector>

    "

    This runs on a custom report with the ID 100005 with filters for last name and post code.
    I assume this is possible through RightNow Connect. I need a code sample (.NET C#) of a similar search to get started.
    Thanks

    Comment

     

    • Walter Kamp

      RNOWAcFilter[] Filters = new RNOWAcFilter[1];

                                  RNOWAcFilter orgidFilter = new RNOWAcFilter();
                                  orgidFilter.FilterId = 1;
                                  orgidFilter.Operator = (int)RNOWUtil.SearchOperator.EQUALS;
                                  orgidFilter.Value = this._org.ID.ToString();
                                  Filters[0] = orgidFilter;

                                  Object[][] SearchResults = of.ExecuteReport(112898, Filters);
                                  List<string> IDList = new List<string>();
                                  if (SearchResults != null && SearchResults.Length > 0)
                                  {
                                      foreach (object[] o in SearchResults)
                                      {
                                          IDList.Add(o[0].ToString());
                                      }
                                  }

    • Sam Kaveh

      Hi,

      I if understand your code right, this is soly for a single filter search. If I had more than one filter would this code work?

      RNOWAcFilter[] Filters = new RNOWAcFilter[2]; //Am I right to asume that the int 2 defines the number of filters?

                                  RNOWAcFilter orgidFilter = new RNOWAcFilter();
                                  orgidFilter.FilterId = 1; //is the int 1 the actual ID for the filter in my report?
                                  orgidFilter.Operator = (int)RNOWUtil.SearchOperator.EQUALS;
                                  orgidFilter.Value = "searchString1";
                                  Filters[0] = orgidFilter;

                                  RNOWAcFilter Filter2 = new RNOWAcFilter();
                                  Filter2.FilterId = 6521; //asuming the int 6521 is the actual ID for the filter in my report
                                  Filter2.Operator = (int)RNOWUtil.SearchOperator.EQUALS;
                                  Filter2.Value = "searchString2";
                                  Filters[1] = Filter2;

                                  Object[][] SearchResults = of.ExecuteReport(112898, Filters);
                                  List<string> IDList = new List<string>();
                                  if (SearchResults != null && SearchResults.Length > 0)
                                  {
                                      foreach (object[] o in SearchResults)
                                      {
                                          IDList.Add(o[0].ToString());
                                      }
                                  }

    • Walter Kamp

      That is almost correct.

      FilterId should be 1,2,3, etc...

      The rest is ok.

    • Sam Kaveh

      I assume 1,2,3, etc would be the order they are added in the report via analytics?

    • Walter Kamp

      Yes, this is correct.

    • Sam Kaveh

      Thanks, have tried the code and it works fine.

      I noticed however that the "Complex Expression" method is not available for the "RNOWUtil.SearchOperator". I am using "LIKE" for now but is there any reason why "Complex Expression" is missing?

    • Walter Kamp

      Don't know that... I always use EQUALS or LIKE.

      Hopefully RightNow can answer this?

    • Ryan McCullough

      For some reason "Complex Expression" was not exposed.

      I would recommend posting this on the idea lab (link at top) and submit an incident to CC asking for this new feature.

      -Ryan

    • ryszard antonczyk

      Sam,

       

      If yopu think that "Complex Expression" is important for your organization and would improve the RN product - please post your idea inside Idea Lab forum.

       

      Thank you,

      Ryszard