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, ...
Unanswered

DirPersonName ValidFrom is not filled automatically by code

(2) ShareShare
ReportReport
Posted on by 54
Hi,

When we create a contact person for a customer manually, then DirPersonName.ValidFrom field gets filled automatically.

However, if we i do it by code, the validFrom field in DirPersonName is not filled
 
  smmContactPersonV2Entity.ContactPersonId                = _contract.ContactPersonId();
  smmContactPersonV2Entity.AssociatedPartyNumber          = _contract.AssociatedPartyNumber();
  smmContactPersonV2Entity.ContactPersonPartyType         = enum2Str(DirPartyType::Person);  
  smmContactPersonV2Entity.FirstName                      = _contract.FirstName();   
  smmContactPersonV2Entity.ContactForParty                = DirPartyTable::find(_contract.AssociatedPartyNumber()).RecId;

  smmContactPersonV2Entity.insert();
 
 
is there a method i need to call?
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    238,193 Most Valuable Professional on at
    Do you mean that you want to explicitly set the data as invalid before the current time?
     
    Please tell us what steps you do in GUI.
     
    You're using an entity - what behaviour do you see when you import the data through data management? You'll see whether it's the normal behavior of the entity or the problem is caused by your code.
     
    Will it make any difference if you call initValue()?
  • Sohaib Cheema Profile Picture
    49,504 User Group Leader on at
    it appears that while the record is created from the UI, it goes through 
    DirPartyBaseEntity >> insertEntityDataSource >> postUpdatePartyBuffer >>
    and this is where the ValidFrom and ValidTo are initialized
     
     
    If values for these fields are not being provided  to entity field, it will take Max and Now values as above:
     
  • Martin Dráb Profile Picture
    238,193 Most Valuable Professional on at
    I wonder the GUI for contact persons really use data entities. smmContactPerson form, for example, uses ContactPerson table as the data source, not smmContactPersonV2Entity.
     
    Nevertheless Sohaib's finding suggest that DirPersonName.ValidFrom is expected to be initialized in the current time if a new record is being inserted. Debug the code to see why it doesn't execute in your case.
  • CU22120935-0 Profile Picture
    54 on at
    Hi All, 

    From the UI, i just go to customers, view contacts, create new contact (fill first name and last name)
    I go to the DB and see that DirPersonName.ValidFrom gets filled with current date time.

    Using entity.initValue() doesn't make a difference, still DirPersonName.ValidFrom is empty (1900)
     
    DirPartyBaseEntity  doesn'r get called from the UI
     
     
    I debugged and I saw it doesn't enter the code that Sohaib mentioned because of savedPersonName= No



    Even though initValue in dirPartyBaseEntity is yes
     
    there is code later that makes it no in mapEntityToDataSource method, which gets called before the code that Sohaib mentioned
     
     
    What is this field savePersonName? and why does it become false later? and how to overcome it?
     

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 763 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 284 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans