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
Laxmaya ChnLaxmaya Chn 

How to crosscheck AccountIDs(Salesforce)

In my project as the data is coming from third party where they are sending data from their end with Salesforce ID(Account). Sometimes they are sending invalid id's(which are not existed in our database for Accounts), hence I need to cross check new incoming ID with existing ID and want to through an error if the ID doesn't exist.
Arun KumarArun Kumar
Hi Laxmaya,

You can write down the apex logic for like below:
1. Create a set 'accountIdSET' for third party Account Ids
2. Query in your current org like 'SELECT ID FROM ACCOUNT WHERE ID IN: accountIdSET
3. Now you can itertae over the list and create a map for map<Id, Account>
4. Now again iterate over the accountIdSET and then check with the recently created map if you will find any account then it's sexisting otherwise not.

Thanks,
Arun