This is a public Forum  publicRSS

Topic

    Steve Flynn
    How to get the CreatedByAccount of a custom object using...Answered
    Topic posted June 16, 2017 by Steve FlynnJourneyer 
    88 Views, 2 Comments
    Title:
    How to get the CreatedByAccount of a custom object using REST
    Content:

    I have a custom object which has the CreatedByAccount predefined field in it.

    In the object designer it tells me it is a Menu type.  In ROQL it tells me it is a table of subtype Account.

    I have tried the following:

    https://example.custhelp.com/services/rest/connect/v1.3/CTI.Event?fields=CreatedByAccount

    CreatedByAccount

    createdByAccount

    createdbyaccount

    All three of the above with the following appendages:

    .lookupname

    .LookupName

    .DisplayName

    .displayname

    .name.last

    I have looked at ...metadata-catalog/CTI.Event and that gives no clues either.

    How do I get the CreatedByAccount of a custom object using REST?

    Best Answer

    Scott Harwell

    CreatedByAccount is a collection and the fields operator does not work on collections...

    Note: Queries on subfields, such as name.first, only work with individual resources and not with collections.
    

    However you can get the collection from the expended view and then perform another request for the account.

    https://example.custhelp.com/services/rest/connect/v1.3/CTI.Event/123456?expand=all
    

    Answer

     

    • Scott Harwell

      CreatedByAccount is a collection and the fields operator does not work on collections...

      Note: Queries on subfields, such as name.first, only work with individual resources and not with collections.
      

      However you can get the collection from the expended view and then perform another request for the account.

      https://example.custhelp.com/services/rest/connect/v1.3/CTI.Event/123456?expand=all
      
    • Bastiaan van der Kooij

      alternatively you could use ROQLto get the ID(s) you like;

      https://example.custhelp.com/services/rest/connect/v1.3/queryResults?query=SELECT CreatedByAccount FROM CTI.Event
      

      Bastiaan