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
JaanuJaanu 

SOQL Query to update the Account Records based on matching Id.

I have a custom object, where I am storing all the outbound messages and processing all the outbound messages one by one. When I process each outbound message, it will write into the data base and I get the unique number from database, which needs to be updated in the Account Object. To do this, I am using SOQL query to extract the matching account record using the record type id from outbound message. (Note: When I am creating the account in salesforce, I write the a.id into the outbound message object.)
SELECT Id, Name, Unique_Number FROM Account WHERE RecordTypeId = :Record_Id__c from outbound message object. (Note: When I am creating the account in salesforce, I write the a.id into the outbound message object into the field Record_Id__c)
The above query is returning more than 30 records ... but I am expecting only record as output.. how this is possible ?? Id is unique for every record right... what is wrong here...
 
Harish DHarish D
Hi Jaanu,

Since you want to query information from Outbound Message Object, you will have to write query on Outbound Message Object to retrieve the record based on the Account Id. Your query would like this, replace the Outbound_Message__c with your custom object name.
 
Select id from Outbound_Message__c where Record_Id__c=:a.id


Thanks,
Harish




 
JaanuJaanu
Thanks Harish ... No... I need to update the account records based on the matching ID from out bound message id with account id. could you pls let me know why I am getting so many results ... I was expecting only one record from account object ...i though ID is unique id. not sure why so many results matching ...am I using incorrect field for matching ???
Narender Singh(Nads)Narender Singh(Nads)
Hi,
I am not sure if I understood your requirement correctly. But the reason you are getting more than one record while querying is because there can be multiple outbound_message object records associated with same account.

I might be able to help you better if you could explain your requirement once more.
Thanks!
devedeve
Hi Jannu,

This is because you are applying RecordTypeId check in Where clause instead of Id and Record_Id__c should be the record_Id__c of outbound message object. Please check using this

SELECT Id, Name, Unique_Number FROM Account WHERE Id = :Record_Id__c