Jump to content

Retrieve related fields with QUERY function on Custom Object


 Share

Recommended Posts

I have a custom object that has relationships to standard objects.  For example, my custom object has a relationship to Vendor, and I've added two related fields for it.

image.thumb.png.9d14f95d86284a21bc839e620fabeb90.png

When I perform a readByQuery function, I am able to select these in the "select" parameter without error.

        <readByQuery>
          <object>offset_history</object>
          <fields>id,RVENDOR,vendor_name</fields>
          <query></query>
          <pagesize>100</pagesize>
        </readByQuery>
 

this successfully returns:

<data listtype="offset_history" count="8" totalcount="8" numremaining="0" resultId="">
                <offset_history>
                    <id>11954</id>
                    <RVENDOR>20062</RVENDOR>
                    <vendor_name>Paramount Consulting</vendor_name>
                </offset_history>

when I try to do the same thing using the QUERY function, I get an error

       <query>
        <object>offset_history</object>
        <select>
            <field>id</field>
            <field>RVENDOR</field>
            <field>vendor_name</field>
        </select>
       </query>

the error is:

                <error>
                    <errorno>XL03000006</errorno>
                    <description></description>
                    <description2>The following fields cannot be queried: [
    offset_history: [vendor_name] ] [Support ID: VCxwjWEB034%7EZvsZ4P5M0Pr4C8C-zu0_ywAAABA]</description2>
                    <correction></correction>
                </error>

I have tried replacing vendor_name with VENDOR.NAME and RVENDOR.NAME and it errors both times.

How can I use the QUERY function on a custom object with relationships?

Link to comment
Share on other sites

 Share

×
×
  • Create New...