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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Validation: Field 'Name' must be filled in

(1) ShareShare
ReportReport
Posted on by 18
Hi,

I'm inserting a record using DirPersonBaseEntity, but i'm getting this error:
Field 'Name' must be filled in.\nvalidateField failed on field 'DirPartyBaseEntity.Name'\n"
How to auto fill it by code?
   DirPersonBaseEntity dirPersonBaseEntity;

   dirPersonBaseEntity.PartyNumber                     = "123";
   dirPersonBaseEntity.FirstName                       = "aa";
   dirPersonBaseEntity.LastName                        = "bb";
   dirPersonBaseEntity.insert();
 
 
However, if i do the same but using DirPersonEntity, it works directly without filling Name and i think it's because of this mapping. What does this mapping do?
 
and what do in base entity to make it work?
Categories:
I have the same question (0)
  • Suggested answer
    Alireza Eshaghzadeh Profile Picture
    14,734 Super User 2025 Season 2 on at
    Hi,

    The keys are PartyNumber and ValidFrom. If either the first name, middle name, last name prefix, or last name has changed, the Name value must be rebuilt.

    Please try adding ValidFrom as part of the key. If that does not resolve the issue, rebuild the Name value accordingly.

  • Martin Dráb Profile Picture
    238,109 Most Valuable Professional on at
    Name seems to be calculated in DirPersonBaseEntity.mapEntityToDataSource(). Debug the code to identify the difference between your two cases.
     
    Maybe you need to call initValue() of DirPersonBaseEntity.
  • Suggested answer
    Alireza Eshaghzadeh Profile Picture
    14,734 Super User 2025 Season 2 on at
    This issue is duplicate of Dynamics Community Forum Thread Details
  • CU22120935-0 Profile Picture
    18 on at
    • initValue fixed the issue directly but i don't know why it was needed for DirPersonBaseEntity and it wasn't needed for DirPersonEntiy
     
    • Regarding validFrom, i agree that i need to fill it, currently when i create a record, valid from is 1900, but when i update the record it's gets filled automatically with currentDateTime even though i didn't specify validFrom by code
      How to fill validFrom in case of insert by code? and how it's handled in update automatically?
     
    **regarding question duplication, i sent an email to the support team, not sure why my questions appear twice in the forum
  • Suggested answer
    Martin Dráb Profile Picture
    238,109 Most Valuable Professional on at
    If you debugged the code as I suggested, you'd have seen the difference.
     
    This is my assumption about what happened:
     
    If you look at the name calculation logic I mentioned, you'll notice that it depends on NameSequenceDisplayAs field. It's initialized in initValue() based on a parameter table. When DirPersonBaseEntity is used by DirPersonEntity, the system calls initValue() correctly. But when you used the entity from your code, you neither set NameSequenceDisplayAs field nor called initValue(), therefore NameSequenceDisplayAs wasn't specified and the name couldn't be calculated.
     
    Please don't forget to verify the answer.

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

News and Announcements

Season of Giving Solutions is Here!

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 679 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 421 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 282 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans