1

I have a junction object called "JIRA_Data" and its linked/ related to Accounts. How do I query to fetch data from this relationship. I am trying to extract id,type from Account object and Name from JIRA_Data junction object.

Could anyone assist. Thanks

  • Can you please elaborate more on your question? You want all those accounts having records in Junction object JIRA_Data. Is it correct? – sfdc_sk Jul 13 '18 at 10:27
  • @sfdc_sk, yes I am trying to have a column that would tell whether the account has value in JIRA_Data. If so, display that corresponding value from JIRA_Data for that Account.. – dark horse Jul 13 '18 at 10:29
0

You can use this query with proper relationship name.

SELECT id,type, 
       (SELECT Name FROM JIRA_DATA__r)
FROM Account
WHERE Id IN:<AccountIds>
0

You will get all Accounts having data in your Junction Object JIRA_Data in below way :

List<Account> accList = [SELECT id,type, (SELECT id, Name FROM JIRA_DATA__r) FROM Account];

Here, JIRA_DATA__r is the relationship name. Enter the correct relationship name of your Account and JIRA_Data objects

You can access records of JIRA_DATA__r as:

for(Account a : accList){
for(JIRA_DATA__c test : a.JIRA_DATA__r){
//logic 
}}
  • Thanks one more novice question. I am trying to pull these records in Python. If I normally pull Accounts data, I would use sf_data_cursor.bulk.Account.query("""SQL code here""") How do I query in the above case where I am querying in the junction object. Thanks.. – dark horse Jul 13 '18 at 10:40
  • @darkhorse, I have updated my answer. Please check if it provides the result you want. – sfdc_sk Jul 13 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.