Reputation: 592
I'm developing a C# application and using Salesforce Partner Soap Api in it. At some point, I need to create a lead from the application(By sending FirstName, LastName, Email, Status fields) which I achieve using SObject and create the method of SForceService which in turn returns me the lead Id and I save it in the db.
After some point they're going to create a contact with the info I sent for lead creation and also assign an Account to it.
Here I need to develop a scheduled job to query and get some information from the Account entity of Salesforce.
Each account in Salesforce has an account number which I don't have it my db, but technically I should be able to query for the contact using the Email and get the account assigned to that contact. This would work only if Emails are enforced to be unique for contacts in Salesforce and each contact can only have one Account assigned to it(Otherwise I wouldn't know which account's info I should fetch).
So my questions are :
Thank you in advance,
Upvotes: 0
Views: 1036
Reputation: 19040
If you have the Lead ID from when the lead was created, which you do, then the Lead SObject will have information about the related contact & account that it was converted to after it was converted. You can use the soql relationships feature to get all this in a single soql query, e.g.
select Id, IsConverted, ConvertedContactID,
convertedContact.Name, convertedContact.Account.Name
from Lead where ID='00Q3000000XjfdzEAB'
Upvotes: 0