Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

Create Entity with custom fields using entity class.

(0) ShareShare
ReportReport
Posted on by

Hi all

I am trying to create entities using the code sample given here.

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/org-service/use-entity-class-create-update-delete

However it works only with standard entity fields. If I include any custom fields, it throws an error

"System.ServiceModel.FaultException`1: ''lead' entity doesn't contain attribute with Name = 'customfieldname' and NameMapping = 'Logical'.'"

I couldn't find any sample to get this to work. Can anyone please point me in the right direction?

Thank you.

Sai.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Create Entity with custom fields using entity class.

    Hello Andrew

    I found the issue with my code, it was a silly mistake on my part. For the custom fields, I wasn't including the prefix before the field name. When I fixed that, it worked fine.

    FWIW, here is the code snippet:

    Entity entity = new Entity("lead");
    entity["lastname"] = "LastName";

    entity["companyname"] = "company";

    entity["new_testcustomfield"] = "customvalue";
    _orgService.Create(entity);

    Thank you.

    Sai.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Create Entity with custom fields using entity class.

    Sai,

    Can you please provide code that you use and that doesn't work?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Dynamics 365 general forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans