function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nilesh ManeNilesh Mane 

How can I get Account ID?

I want to send an email to all contacts which  belongs to  a single account.

I want to get their corresponding  Account ID in batch apex dynamically.

How can I get Account ID?

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Can you clarify your use case a little?  Are you planning to iterate all accounts and send an email to all contacts associated with the account?  If so, it sounds like you'll be using batch apex with a querylocator that pulls back all accounts. Your execute method will then be passed a list of accounts, and you can iterate these and pull back the contacts.

 

Note though, that there are limits on the amount of emails that you can send on a daily basis.

All Answers

bob_buzzardbob_buzzard

If you have the contact records, they have a standard field populated with the account id named 'AccountId'.

Nilesh ManeNilesh Mane

Thanks for reply.

 

I want process apex job for a single Account at a time.

How will compiler know for which account i am running the job? plz help.

bob_buzzardbob_buzzard

Can you clarify your use case a little?  Are you planning to iterate all accounts and send an email to all contacts associated with the account?  If so, it sounds like you'll be using batch apex with a querylocator that pulls back all accounts. Your execute method will then be passed a list of accounts, and you can iterate these and pull back the contacts.

 

Note though, that there are limits on the amount of emails that you can send on a daily basis.

This was selected as the best answer