You need to sign in to do that
Don't have an account?
query by custom id
I am new to apex and the idea to bulkify. I have a table that will be updated. I then take these updates and modify an account/contact based on an ID other than the Salesforce ID. I can't seem to find any examples of doing this but imagine that it must be possible. I am doing this in a class and not the trigger.
I have found several examples on how to query the data via the Salesforce ID but not an alternate field. Currently I am putting all the changes that are being requested into a list. I then want to take that list of IDs(custom id) and query the data.
//Here are the account that I want to update
list<Account> accounts
//Here I am creating a set of the ids to query from
Set <ID> aId = new Set<ID>();
for (Account ac : accounts)
aID.add(ac.mtp_Account_ID__c);
//here I want to query all the accounts in the list above.
List<Account> AccountExists = [select id,MTP_Account_ID__c from Account where MTP_Account_ID__c in :aid];
I get that the number being passed is an invalid ID. Which is true if looking for Salesforce ID but I want to use my custom ID to query from. I not sure what I am missing....
Thanks,
Tena
Try the following and let me know if it works:
Regards,
Sumit