You need to sign in to do that
Don't have an account?
jisakc1
I need query help!
I have a custom object, a junction table and Accounts I need to pull from the junction table. The message is the it doesn't understand the relationship reqCH in the query. What am I missing here????
Here is the query ( stripped out pieces so syntax may not be right but the piece in bold is what causes the error because if I take it out I can save.):
DCS_Request__c reqCH = [SELECT Id, CRM_Account__c, CRM_Account__r.CRM_Parent_Account_Ultimate__c, CRM_Account__r.CRM_Credit_Parent__c
,CRM_Account__r.ParentID, CRM_Account__r.CRM_Credit_Ultimate__c
FROM DCS_Request__c WHERE ID =: req.Id LIMIT 1];
j = [SELECT Name, ,CRM_ChildAcct__c, CRM_DCS_Request_ID__c
, CRM_Allow_Parent__c, CRM_Allow_Ult_Parent__c, CRM_Account_ID__c, CRM_Account_ID__r.Name
, CRM_Account_Id__r.ParentId, CRM_Account_Id__r.CRM_Parent_Account_Ultimate__c
, CRM_ChildAcct__r.ParentId, CRM_ChildAcct__r.CRM_Parent_Account_Ultimate__c
, CRM_DCS_Request_ID__r.CRM_Account__c, CRM_DCS_Request_ID__r.Id
FROM CRM_Junctions__c WHERE (
((CRM_ChildAcct__c =:reqCH.CRM_Account__c)
OR ( CRM_Account_ID__c =: reqCH.CRM_Account__c AND CRM_ChildAcct__c = null)
OR (CRM_Account_ID__c =: reqCH.CRM_Account__r.ParentID and CRM_ChildAcct__c = null and reqCH.CRM_Account__r.CRM_Credit_Parent__c = true)
AND RecordType.Name = 'Junction' ) order by LastModifiedDate DESC Limit 10];
Here is the query ( stripped out pieces so syntax may not be right but the piece in bold is what causes the error because if I take it out I can save.):
DCS_Request__c reqCH = [SELECT Id, CRM_Account__c, CRM_Account__r.CRM_Parent_Account_Ultimate__c, CRM_Account__r.CRM_Credit_Parent__c
,CRM_Account__r.ParentID, CRM_Account__r.CRM_Credit_Ultimate__c
FROM DCS_Request__c WHERE ID =: req.Id LIMIT 1];
j = [SELECT Name, ,CRM_ChildAcct__c, CRM_DCS_Request_ID__c
, CRM_Allow_Parent__c, CRM_Allow_Ult_Parent__c, CRM_Account_ID__c, CRM_Account_ID__r.Name
, CRM_Account_Id__r.ParentId, CRM_Account_Id__r.CRM_Parent_Account_Ultimate__c
, CRM_ChildAcct__r.ParentId, CRM_ChildAcct__r.CRM_Parent_Account_Ultimate__c
, CRM_DCS_Request_ID__r.CRM_Account__c, CRM_DCS_Request_ID__r.Id
FROM CRM_Junctions__c WHERE (
((CRM_ChildAcct__c =:reqCH.CRM_Account__c)
OR ( CRM_Account_ID__c =: reqCH.CRM_Account__c AND CRM_ChildAcct__c = null)
OR (CRM_Account_ID__c =: reqCH.CRM_Account__r.ParentID and CRM_ChildAcct__c = null and reqCH.CRM_Account__r.CRM_Credit_Parent__c = true)
AND RecordType.Name = 'Junction' ) order by LastModifiedDate DESC Limit 10];
Please try by removing "reqCH." in the bold part. Something like this:
If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.
Thanks,
Shashank