Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How can we create an entity record with more than 300 attributes?

Posted on by Microsoft Employee

I have created a Web API which would get data foir more than 300 attributes from json and create an entity record  with around 300 attributes.How can this be achieved with such  large number of attributes for the the entity.

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can we create an entity record with more than 300 attributes?

    Hi,

    This is not possible by one entity

    I have a trick for this. you can create an extension entity for other fields (over 300)

    for ex.

    Create two entities A and A-ext. Create the lookup of A on A-ext and lookup of A-ext on A.

    Hope you can understand what I mean.

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    Shahbaaz Ansari 6,203 on at
    RE: How can we create an entity record with more than 300 attributes?

    Hi CRM,

    Have you  tried creating a record with 300 attributes? if yes, did you get any error? if yes please share.

    Thanks,

    Shahbaaz

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can we create an entity record with more than 300 attributes?

    But, this is not practically possible for such a large number of attributes

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How can we create an entity record with more than 300 attributes?

    Hi,

    You can use the batch request to executing large FetchXML requests.

    e.g.

    var req = new XMLHttpRequest();

    req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/$batch", true);

    req.setRequestHeader("OData-MaxVersion", "4.0");

    req.setRequestHeader("OData-Version", "4.0");

    req.setRequestHeader("Accept", "application/json");

    req.setRequestHeader("Content-Type", "multipart/mixed;boundary=batch_contactfetch");

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           req.onreadystatechange = null;

           if (this.status === 200) {

               var response = JSON.parse(this.response.substring(this.response.indexOf('{'),this.response.lastIndexOf('}')+1));

    console.log(response.value);

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    var body = '--batch_contactfetch\n'

    body += 'Content-Type: application/http\n'

    body += 'Content-Transfer-Encoding: binary\n'

    body += '\n'

    body += 'GET ' + Xrm.Page.context.getClientUrl()+'/api/data/v8.2/contacts?fetchXml=<fetch count="10" ><entity name="contact" ><attribute name="fullname" /></entity></fetch> HTTP/1.1\n'

    body += 'Content-Type: application/json\n'

    body += 'OData-Version: 4.0\n'

    body += 'OData-MaxVersion: 4.0\n'

    body += '\n'

    body += '--batch_contactfetch--'

    req.send(body);

    Thank You

  • Suggested answer
    Shahbaaz Ansari Profile Picture
    Shahbaaz Ansari 6,203 on at
    RE: How can we create an entity record with more than 300 attributes?

    try like this


    Entity entity = new Entity("Entityname");

    entity["field1"] = "value1";
    entity["field2"] = "value2";
    entity["field3"] = "value3";
    ..
    ..
    ..
    ..
    ..
    entity["field300"] = "value300";

    _service.Create(entity);

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