Dynamics CRM 2015/2016/365 Web API: cascading creation

Source: Internet
Author: User

Cascading is created so that when you create a master record, you can create a new record associated with it. For example, after we create a customer record, we typically need to create a contact record and then set the contact record as the primary contact for that account record.

In the above example, if we do this in the traditional way, we need to request the server 3 times to complete, if the relevant record data involved, then the number of requests also need to increase. But if we use the cascading creation capabilities of the Web API, we only need to make one request to the server.

Cascading creation is consistent with the request for normal creation, and the only difference is how to construct the object to be recorded. We continue to use the example above, and we intend to create a customer record and create a record of the primary contact with which it manages, so this creation object is constructed as follows:

Jobject account = new Jobject ();            Account. ADD ("Name", Stringgenerator (Numbergenerator ()));            Jobject primarycontact = new Jobject ();            Primarycontact.add ("LastName", Stringgenerator (Numbergenerator ()));            Account. ADD ("Primarycontactid", primarycontact);          

When everything is ready, we commit the object using the following C # code, so that we can complete the requirements of the last scenario description in a single request.

     Httprequestmessage req = new Httprequestmessage (Httpmethod.post, "accounts");            Req. Content = new Stringcontent (Jsonconvert.serializeobject (account), Encoding.UTF8, "Application/json");            Httpresponsemessage resp = await _client. SendAsync (req);


Dynamics CRM 2015/2016/365 Web API: cascading creation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.