Solved

Attached Contact to Account

Posted on 2012-03-29
2
427 Views
Last Modified: 2012-04-16
I ma using the code below to add a new contact and attach it to an account.  The contact gets added OK but the parentcustomerid does not seem to get added.


 
Private Function AddNewContact(ParentAccount As Guid, ParentAccountName As String, Firstname As String, Lastname As String, Email As String, Tel As String) As Guid

        Dim newcontact As New Entity()
        newcontact.LogicalName = "contact"

        Dim newcontactColl As New AttributeCollection()
        newcontactColl.Add(New KeyValuePair(Of String, Object)("parentcustomeridtype", 1))
        newcontactColl.Add(New KeyValuePair(Of String, Object)("parentcustomeridname", "parentcustomerid"))
        newcontactColl.Add(New KeyValuePair(Of String, Object)("parentcustomerid", ParentAccount))
        newcontactColl.Add(New KeyValuePair(Of String, Object)("firstname", Firstname))
        newcontactColl.Add(New KeyValuePair(Of String, Object)("lastname", Lastname))
        newcontactColl.Add(New KeyValuePair(Of String, Object)("telephone1", Tel))
        newcontactColl.Add(New KeyValuePair(Of String, Object)("emailaddress1", Email))
        newcontact.Attributes = newcontactColl

        Dim ContactID As Guid
        ContactID = Client.Create(newcontact)

        Return ContactID

    End Function

Open in new window

0
Comment
Question by:Kevin Robinson
2 Comments
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 500 total points
ID: 37787056
Hi VolunteerDevelopmentAgency,

newcontactColl.Add(New KeyValuePair(Of String, Object)("parentcustomeridtype", 1))
newcontactColl.Add(New KeyValuePair(Of String, Object)("parentcustomeridname", "parentcustomerid"))
newcontactColl.Add(New KeyValuePair(Of String, Object)("parentcustomerid", ParentAccount))

Open in new window

               

I think it should be like this
newcontactColl.Add(New KeyValuePair(Of String, Object)("parentcustomerid", new EntityReference("account", parentcustomerid)))

Open in new window


If this code does not work then sorry as I am not comfortable with VB.Net, I have provided a C# style code.

Regards,
Chinmay.
0
 
LVL 3

Author Closing Comment

by:Kevin Robinson
ID: 37850211
Thanks
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Smart Phone connection problem to Windows 2003 SBS server 24 57
Dynamics GP--Applying a Sales Return to an Invoice 1 608
CRM 2016 Cloud Web Development 2 61
Dynamics crm 2011 8 95
On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part I
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question