Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Vignesh Kasargod
    [Help] To fetch the Email Address details for an Account...Answered
    Topic posted August 25, 2014 by Vignesh KasargodBronze Medal: 1,250+ Points, last edited August 25, 2014 
    300 Views, 4 Comments
    Title:
    [Help] To fetch the Email Address details for an Account Object
    Content:

    Hi Friends,

    I am trying to fetch the Email Address details for an Account Object using QueryObject operation. 

    Email Address Object being a sub object for an Account Object, I would need to request for the details in the 'ObjectTemplate' . Below is the code snippet for the same:

    <v1:QueryObjects>
    <v1:Query>SELECT Account FROM Account WHERE ID = 17;</v1:Query>
    <v1:ObjectTemplates xmlns:ns4="urn:objects.ws.rightnow.com/v1_2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns4:Account">
    <ns4:Emails/>
    </v1:ObjectTemplates>
    </v1:QueryObjects>

    Unfortunately , this is not returning me the Email Address details.

    Earlier I had tried the same approach on the Contact object as per the below code snippet: 

    <v1:QueryObjects>
    <v1:Query>SELECT Contact FROM Contact WHERE ID = 46;</v1:Query>
    <v1:ObjectTemplates xmlns:ns4="urn:objects.ws.rightnow.com/v1_2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns4:Contact">
    <ns4:Emails/>
    </v1:ObjectTemplates>
    </v1:QueryObjects>

    It worked and I was able to get the Email Address details for the Contact object.

    Can any one help me to understand on why the mentioned approach is not working on the Account Object.

    Regards, 
    Vignesh Kasargod   

    Best Comment

    Allan Schrum

    Your posted question indicated QueryCSV but your request shows QueryObject. It you use QueryCSV try:

    SELECT Emails.Address, Emails.AddressType, Emails.Certficate, Emails.Invalid FROM Account WHERE ID = ***

    For QueryObjects, your approach is correct. Are you sure the Account indicated has an email address to return?

    Regards,

    -Allan

    Comment

     

    • Suresh Thirukoti

      You can fetch email address of account by the below code ...

               String qry="Select Account From Account A where A.ID=XX";
                  Account acc =new Account();
                  acc.Emails =new Email[] {};        //Need to declare this

                  QueryResultData[] qrd=rspc.QueryObjects(new ClientInfoHeader { AppID="XX"}, qry,new RNObject[] { acc},1000);
                  RNObject[] res = qrd[0].RNObjectsResult;

                  acc = res[0] as Account;

                  MessageBox.Show(acc.Emails[0].Address);

       

      ~Suresh

    • Vignesh Kasargod

      Thanks Suresh, 

      I was looking on something related in creating the SOAP request. 

      Regards, 

      Vignesh Kasargod 

    • Allan Schrum

      Your posted question indicated QueryCSV but your request shows QueryObject. It you use QueryCSV try:

      SELECT Emails.Address, Emails.AddressType, Emails.Certficate, Emails.Invalid FROM Account WHERE ID = ***

      For QueryObjects, your approach is correct. Are you sure the Account indicated has an email address to return?

      Regards,

      -Allan

    • Vignesh Kasargod

      Hi Allan, 

      Thanks again for your help and also notifying me on my typo. I have accordingly edited my post now.

      I am able to access the e-mail address with the 'QueryObject' operation on the Account Object.

      The Account indicated has an email address, but I had wrongly created my ObjectTemplates.

      Regards, 

      Vignesh Kasargod