Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Charlie Mopps
    Change incident primary contact in 1 api call?Answered
    Topic posted February 8, 2016 by Charlie MoppsGold Medal: 3,500+ Points 
    223 Views, 5 Comments
    Title:
    Change incident primary contact in 1 api call?
    Content:

    I make an API call to change the contact on an incident. But it seems to set the contact, I need to know the c_id. So I have to make 2 api calls... 1 to look up the contact via a custom field or email address and then a second to set the contacts primary contact to the id I found in the lookup. But one of my external applications has a technical limitation that makes 2 calls difficult.

    1. Is there an easier way to do this in a single call?
    2. Do I have to use Chaining? If so, is there a decent example of what I'm talking about anywhere? I've been trying to setup chaining in a C# applicaiton but the RN API is odd to say the least and I'm not making a lot of progress.

    Thanks!

    Best Comment

    Allan Schrum

    This is a simple example of using a chaining in a single request (not quite yours, but it should demonstrate the ability). Within a Batch request I can have:

    <rnm:BatchRequestItem>
      <rnm:QueryCSVMsg>
        <rnm:Query>
          SELECT ID AS '@Con', Name FROM Contact WHERE Login = 'Fred'
        </rnm:Query>
      </rnm:QueryCSVMsg>
    </rnm:BatchRequestItem>

    <rnm:BatchRequestItem>
      <rnm:GetMsg>
        <rnm:RNObjects xsi:type='rno:Contact'>
          <rnok:ID xsi:type='rnb:ChainDestinationID' variableName='Con'/>
        </rnm:RNObjects>
        <rnm:ProcessingOptions>
          <rnm:FetchAllNames>true</rnm:FetchAllNames>
        </rnm:ProcessingOptions>
      </rnm:GetMsg>
    </rnm:BatchRequestItem>

    Obviously this could be done in a single QueryObjects request, but the demonstration is how we can set the variable using QueryCSV and, using that variable, perform another operation. The first BatchRequestItem will return results that you will ignore but will have the side-effect of setting the Chain variable 'Con'. The follow-up request creates a ChainDestinationID with variable name 'Con' and uses it however it is needed to be used (such as setting the Primary Contact of an Incident).

    Regards,

    -Allan

     

    Comment

     

    • Allan Schrum

      Use chaining within a Batch request. A ROQL query to look up the Contact and associating it to a ChainSourceID. Then use it in the Update call on the Incident. See the documentation on how to set chains with ROQL, but it is like this:

      SELECT ID AS '@MyContact' FROM Contact WHERE ...

      That set the ChainSourceID variable MyContact. Use that variable in the Update request. Just to round things out, ROQL can use chaining in its WHERE clause:

      SELECT ID FROM Contact WHERE Organization = @MyOrganization

      Regards,

      -Allan

    • Charlie Mopps

      The ROQL request isn't an issue. Writing the chaining in C# is the issue. I've been playing around with the demo code but the way those source and destination variables work is what's confusing me. Do you have any links/examples of an ROQL request that provides the data required for the update? This whole thing is building an XML request that somehow tells the API "Make the results of X the input of Y" and that XML is my real goal.

    • Allan Schrum

      This is a simple example of using a chaining in a single request (not quite yours, but it should demonstrate the ability). Within a Batch request I can have:

      <rnm:BatchRequestItem>
        <rnm:QueryCSVMsg>
          <rnm:Query>
            SELECT ID AS '@Con', Name FROM Contact WHERE Login = 'Fred'
          </rnm:Query>
        </rnm:QueryCSVMsg>
      </rnm:BatchRequestItem>

      <rnm:BatchRequestItem>
        <rnm:GetMsg>
          <rnm:RNObjects xsi:type='rno:Contact'>
            <rnok:ID xsi:type='rnb:ChainDestinationID' variableName='Con'/>
          </rnm:RNObjects>
          <rnm:ProcessingOptions>
            <rnm:FetchAllNames>true</rnm:FetchAllNames>
          </rnm:ProcessingOptions>
        </rnm:GetMsg>
      </rnm:BatchRequestItem>

      Obviously this could be done in a single QueryObjects request, but the demonstration is how we can set the variable using QueryCSV and, using that variable, perform another operation. The first BatchRequestItem will return results that you will ignore but will have the side-effect of setting the Chain variable 'Con'. The follow-up request creates a ChainDestinationID with variable name 'Con' and uses it however it is needed to be used (such as setting the Primary Contact of an Incident).

      Regards,

      -Allan

       

    • Charlie Mopps

      Perfect, thank you! I'll try and piece it together from there.

    • Ajith Errabelly
      Allan Schrum said:

      This is a simple example of using a chaining in a single request (not quite yours, but it should demonstrate the ability). Within a Batch request I can have:

      <rnm:BatchRequestItem>
        <rnm:QueryCSVMsg>
          <rnm:Query>
            SELECT ID AS '@Con', Name FROM Contact WHERE Login = 'Fred'
          </rnm:Query>
        </rnm:QueryCSVMsg>
      </rnm:BatchRequestItem>

      <rnm:BatchRequestItem>
        <rnm:GetMsg>
          <rnm:RNObjects xsi:type='rno:Contact'>
            <rnok:ID xsi:type='rnb:ChainDestinationID' variableName='Con'/>
          </rnm:RNObjects>
          <rnm:ProcessingOptions>
            <rnm:FetchAllNames>true</rnm:FetchAllNames>
          </rnm:ProcessingOptions>
        </rnm:GetMsg>
      </rnm:BatchRequestItem>

      Obviously this could be done in a single QueryObjects request, but the demonstration is how we can set the variable using QueryCSV and, using that variable, perform another operation. The first BatchRequestItem will return results that you will ignore but will have the side-effect of setting the Chain variable 'Con'. The follow-up request creates a ChainDestinationID with variable name 'Con' and uses it however it is needed to be used (such as setting the Primary Contact of an Incident).

      Regards,

      -Allan

       

      View original

      This batch chain works for only one record, if the select query returns more than one record how to implement this chaining concept?