web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM insert record with relationship entities.

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    refer to below post on how to perform CRUD using c#.

    msdn.microsoft.com/.../gg328416.aspx

    msdn.microsoft.com/.../gg309731.aspx

  • Community Member Profile Picture
    on at

    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.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    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
    on at

    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
    33,628 on at
  • Community Member Profile Picture
    on at

    thanks,

    I am using OrganizationService  with c#.

  • Suggested answer
    Shaminderpal Singh Profile Picture
    1,565 on at

    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

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    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" .

  • Community Member Profile Picture
    on at

    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
    Shaminderpal Singh Profile Picture
    1,565 on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans