Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

CRM insert record with relationship entities.

Posted on by Microsoft Employee

HI all,

I have relationship with multiple entities like parent  account entity with child entities (task,appointment contact).

I tried to insert record with following link  but not working ,i think that is for (M:M):
http://charanmandya.blogspot.in/search?q=associate

I am developing a html webform to insert data from html webform to Dynamic CRM using C# and everything will dynamic like parent and child entities as well as that's fields also. 

Thanks

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM insert record with relationship entities.

    Hi Shaminderpal,
    I have done all things that are required to crm solution except record insert from webform to CRM. my CRMweb looking like.
    CRMWEBFORM.png

  • Suggested answer
    Shaminderpal Singh Profile Picture
    Shaminderpal Singh 1,565 on at
    RE: CRM insert record with relationship entities.

    Hi Akram,

    The code will execute from html only as you want to do your logic in C# that is the reason we will be using action,your html will invoke action which will handle your request in C# and do the operations and return the result.

    It will be much like  a SOA architecture where your front page will pass request and a separate action will act as a web method to full fill the coming input.

    Alternatively,if you want to execute from JS only,you can always use CRM's web api exposed and making xmlhttprequest.

    Hope this helps.

    Regards,

    Shaminder

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM insert record with relationship entities.

    Thanks Shaminderpal,

    I don't need to plugin , I need to insert record from html webfrom  that user set in crm solution and got all entities and fields in a web application  ,generated a html form according to crm solution setting that user has done.

    my solution is like power webform:

    www.powerobjects.com/.../powerwebform

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: CRM insert record with relationship entities.

    Hi,

    Then you should use the first link i shared to you, you need to make the html field id to be same as the crm field schema name.

    so when comes to c# code,

    contact.Attributes["parentaccountid"]   <--- pass the field id from html  into " parentaccountid" .

  • Suggested answer
    Shaminderpal Singh Profile Picture
    Shaminderpal Singh 1,565 on at
    RE: CRM insert record with relationship entities.

    Hi Akram,

    We can achieve this in web resource.Follow below steps:

    1)Create an action in CRM

    2)Pass your parent entity reference and child entity names as well as parameters in json as as input to action

    3)Write a plugin on that action where you will be able to do C# stuff

    4)Call action from Js

    Regards,

    Shaminder

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM insert record with relationship entities.

    thanks,

    I am using OrganizationService  with c#.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM insert record with relationship entities.

    Actually, I am developing a CRM solution to create html web from to insert record from webform to crm ,so all fields and entities are dynamic with one to many relationship .

    so i can,t set  field name  like " contact.Attributes["parentaccountid"] " beacuse this is not compulsory that to insert only in lookup field.  

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: CRM insert record with relationship entities.

    Hi,

    Example (both records are exist)

    Account and contact 1:N

    i wan to update the account field in contact.

     Entity contact = new Entity("contact");  // provide the entity name

     contact.Id = "contactid";  // you need to provide the current record id in guid format.

     contact.Attributes["parentaccountid"] = new EntityReference("account", "accountid");

    // parentaccountid is the lookup field schema name ,  for the entitureference, firt provide the entity name for that lookup and follow by the accountid in guid format.

     service.Update(contact);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM insert record with relationship entities.

    Thanks Wei Jie Fun for quick reply,

    I need to insert record from parent to child that means a parent entity have relationship with multiple child's entities.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans