0
votes

I need to do 1 of two things (I believe):

  • 1- Get a Custom Object ID so I can query it directly
  • 2- Get a list of values of a specific field within the Object entries.

Ultimate End goal:

  • Add and modify rows in my custom object via external API. However to do this I need to check and make sure my new entry/row does not already exist.

What I have:

I have a custom object (called Customer_Arrays__c). It is a table that I can add new rows to (I will call entrys). Each entry has 6 or 7 fields. 1 of these fields is called (external_ID__c). This is the field I utilize to match to new incoming data to see if the entry already exists, or if it needs to add a new row to my table. This Customer_Arrays__c is a child to my opportunity I believe – it is part of every opportunity and each line item I add has a field defaulted to the opportunity.

Help I need:

  • 1- How do I query the value of my Cutomer_Arrays__c based upon an opportunity ID?
  • 2- How do I query a list of values in my (external_ID__c) based upon an opportunity ID?

Thanks for your help! I have read half a dozen+ posts on similar topics and am missing something. Examples of some Past try's that failed:

  • Select external_ID__c,FROM Custom_Arrays__c WHERE Opportunity='00...'
  • Select Id (Select ID, Custom_Arrays__c from Custom_Arrays__c) from Opportunity where id ='00...'
  • List FROM Custom_Arrays__c WHERE Opportunity='00...'
  • Select Id, external_ID__c, (Select external_ID__c FROM Custom_Arrays__c) WHERE Opportunity__c='00...'

Thanks again!

2

2 Answers

0
votes

Only you know how did you name the lookup field (foreign key) from arrays to Opportunity. You'll need to check in setup, next to where external_ID__c is. Since it's a custom field (gets __c at the end), my guess is you went with default.

Try

SELECT Id, Name, External_Id__c
FROM Customer_Arrays__c
WHERE Opportunity__c = '006...'
0
votes

Thank you eyescream, that got me almost all the way there. Turns out I also needed a __r for the parent child relationship.

Here is a snip out of my final code that works - I think it covers everything:

SELECT Field1__c, Opportunity__r.Id, Opportunity__r.Opportunity__c, FROM Customer_Arrays__c WHERE Opportunity__r.Id = '006...'.

Thank you so very much!!!