Understanding TargetRelatedLeadToAccount class in CRM


I saw one question in Microsoft CRM Development forum, it was regarding the TargetRelatedLeadToAccount class. The user was using this class to update the originatinglead attribute in the account record.

This is how we would be using that class

CrmService service = new CrmService();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.CrmAuthenticationTokenValue = new CrmAuthenticationToken();
service.CrmAuthenticationTokenValue.AuthenticationType = 0;
service.CrmAuthenticationTokenValue.OrganizationName = “orgName”;

TargetRelatedLeadToAccount targetRlTA = new TargetRelatedLeadToAccount();
targetRlTA.AccountId = new Guid(“accountGuid”);
targetRlTA.LeadId = new Guid(“leadGuid”);

SetRelatedRequest srelReq = new SetRelatedRequest();
srelReq.Target = targetRlTA;
SetRelatedResponse srelRes = (SetRelatedResponse)service.Execute(srelReq);

However as it turned out, this class associates an account record to a particular lead record. It doesn’t update the originatinglead attribute in the account record.

We can find a N:N relationships defined between lead and account named “accountleads_association”. Every time we use the above message a particular account record gets associated to the lead.

We can check for it in the following filtered view “FilteredAccountLeads”.



Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

One thought on “Understanding TargetRelatedLeadToAccount class in CRM”

  1. Hello Nishant Rana,

    Thankyou for this overview as I cannot see any information on this in the SDK.

    Do have have an idea what having records in the many to many relationship actually acheives?

    We cannot even add these relationships to be shown on the form, and the relationship does not link the activities from the lead like with ‘originating lead’ attribute?



Please share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.