• Florian Boulet
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Hello,

I'm getting the following data :
SELECT 
  Id,
  Contact.Id,
  Contact.Name,
  Contact.AccountId,
  Contact.Account.Name 
FROM CampaignMember
WHERE Campaign.Type = 'Programme Application'
Now for each row I would like the count of each contact in the account with a CampaignMember.
SELECT 
  COUNT()  
FROM CampaignMember
WHERE Contact.AccountId = $$CURRENT_CONTACT_ACCOUNT$$
I tried the following but it doesn't works :
SELECT 
  Id,
  Contact.Id,
  Contact.Name,
  Contact.AccountId,
  Contact.Account.Name,
  (SELECT 
       COUNT()  
   FROM CampaignMember cm2
   WHERE cm2.Contact.AccountId = cm.Contact.AccountId) as countMDC  
FROM CampaignMember cm
WHERE Campaign.Type = 'Programme Application'
With APEX i tried to parse every row of the first query to run the second query, but i can't access the Contact.AccountId value of each row. The returned object is a CampaignMember with only ContacId, CampaignMemberID and CampaignId.
for(SObject currentContact : [SELECT 
	                          Id,
							  Contact.Id,
							  Contact.Name,
							  Contact.AccountId,
							  Contact.Account.Name 
							  FROM CampaignMember
							  WHERE Campaign.Type = 'Programme Application']){
			System.debug(currentContact);
}
The foreach result
Have you any idea how to do it ? It looks very simple problem but i'm stuck since few hours now ... oO'
Hello,

In account button setting, I can choose to run my lightning component when user click on New Account button. But sadly, in a contact form, in the Account field, if they click New Account it run the default layout.

How can i change it to have the same New Account form everywhere?

Thanks for your help.
Hello,

I'm getting the following data :
SELECT 
  Id,
  Contact.Id,
  Contact.Name,
  Contact.AccountId,
  Contact.Account.Name 
FROM CampaignMember
WHERE Campaign.Type = 'Programme Application'
Now for each row I would like the count of each contact in the account with a CampaignMember.
SELECT 
  COUNT()  
FROM CampaignMember
WHERE Contact.AccountId = $$CURRENT_CONTACT_ACCOUNT$$
I tried the following but it doesn't works :
SELECT 
  Id,
  Contact.Id,
  Contact.Name,
  Contact.AccountId,
  Contact.Account.Name,
  (SELECT 
       COUNT()  
   FROM CampaignMember cm2
   WHERE cm2.Contact.AccountId = cm.Contact.AccountId) as countMDC  
FROM CampaignMember cm
WHERE Campaign.Type = 'Programme Application'
With APEX i tried to parse every row of the first query to run the second query, but i can't access the Contact.AccountId value of each row. The returned object is a CampaignMember with only ContacId, CampaignMemberID and CampaignId.
for(SObject currentContact : [SELECT 
	                          Id,
							  Contact.Id,
							  Contact.Name,
							  Contact.AccountId,
							  Contact.Account.Name 
							  FROM CampaignMember
							  WHERE Campaign.Type = 'Programme Application']){
			System.debug(currentContact);
}
The foreach result
Have you any idea how to do it ? It looks very simple problem but i'm stuck since few hours now ... oO'
Hello,

I'm getting the following data :
SELECT 
  Id,
  Contact.Id,
  Contact.Name,
  Contact.AccountId,
  Contact.Account.Name 
FROM CampaignMember
WHERE Campaign.Type = 'Programme Application'
Now for each row I would like the count of each contact in the account with a CampaignMember.
SELECT 
  COUNT()  
FROM CampaignMember
WHERE Contact.AccountId = $$CURRENT_CONTACT_ACCOUNT$$
I tried the following but it doesn't works :
SELECT 
  Id,
  Contact.Id,
  Contact.Name,
  Contact.AccountId,
  Contact.Account.Name,
  (SELECT 
       COUNT()  
   FROM CampaignMember cm2
   WHERE cm2.Contact.AccountId = cm.Contact.AccountId) as countMDC  
FROM CampaignMember cm
WHERE Campaign.Type = 'Programme Application'
With APEX i tried to parse every row of the first query to run the second query, but i can't access the Contact.AccountId value of each row. The returned object is a CampaignMember with only ContacId, CampaignMemberID and CampaignId.
for(SObject currentContact : [SELECT 
	                          Id,
							  Contact.Id,
							  Contact.Name,
							  Contact.AccountId,
							  Contact.Account.Name 
							  FROM CampaignMember
							  WHERE Campaign.Type = 'Programme Application']){
			System.debug(currentContact);
}
The foreach result
Have you any idea how to do it ? It looks very simple problem but i'm stuck since few hours now ... oO'
Hello,

In account button setting, I can choose to run my lightning component when user click on New Account button. But sadly, in a contact form, in the Account field, if they click New Account it run the default layout.

How can i change it to have the same New Account form everywhere?

Thanks for your help.