Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / Custom data entity not...
Finance forum
Suggested answer

Custom data entity not calling validateWrite()

Posted on by 112
Hello:
I created a custom data entity based on a custom table. In testing, I found a number of issues. First, the table has a validateWrite() which works when I create records from the custom form attached to that table, but validateWrite() is not called using a DM job using that entity. I've tried adding validateWrite() and validateField() to the entity without success. Secondly, when I use the public collection name in the url (i.e., https://.../data/[public collection name]), no records are returned. I'll add that I created the entity by duplicating and modifying an existing entity. 
  • Layan Jwei Profile Picture
    Layan Jwei 3,204 Super User on at
    Custom data entity not calling validateWrite()
    Hi Community member,

    I'm glad your issue is fixed. Please don't forget to verify the answers that helped.
  • CU29041349-0 Profile Picture
    CU29041349-0 112 on at
    Custom data entity not calling validateWrite()
    Hi Andre,
    I did try the wizard but I ran into that common error (natural key???). 
    I went ahead and recreated my entity, and this time it worked. Validation on the custom table was being called as expected. Still not sure why I went wrong though. Thank you for your attempts to help.
  • Andre Arnaud de Calavon Profile Picture
    Andre Arnaud de Cal... 283,414 Super User on at
    Custom data entity not calling validateWrite()
    Hi,

    You mentioned you duplicated the entity from another one. Have you also tried creating a new data entity using the wizard in Visual Studio?
  • Layan Jwei Profile Picture
    Layan Jwei 3,204 Super User on at
    Custom data entity not calling validateWrite()
    Yes it could be that sth went wrong while copying it because validate write should be called. Update us please with your findings.
     
    And did calling the url work now after adding cross-company?
     
    When your issue is fixed, then please don't forget to verify the answers that helped.
  • CU29041349-0 Profile Picture
    CU29041349-0 112 on at
    Custom data entity not calling validateWrite()
    Layan,
    The original DE does call validateWrite(). 
    I must have misconfigured something with the new DE.
    It didn't take much time to build the DE so I'm going to delete the one I have and rebuild it. Fingers crossed. 
  • Layan Jwei Profile Picture
    Layan Jwei 3,204 Super User on at
    Custom data entity not calling validateWrite()
    Hi Community member,
     
    If u import using the original entity, does the validateWrite of the table gets called when you import?
     
    Regarding records not being returned, if you want to return records from a legal entity that is not equal to the user default legal entity, then you need to use cross-company=true 
     
    http://[baseURI\]/data/FleetCustomers?$filter=dataAreaId eq 'usrt'&cross-company=true

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     
  • CU29041349-0 Profile Picture
    CU29041349-0 112 on at
    Custom data entity not calling validateWrite()
    Mohamed,
    I did build and sync as well as refreshed the entity list. The entity is available for the DM import / export jobs. Because the custom form and the entity is tied to the same custom table, even the Open in Excel template is available. The main issue is my validation code on the custom table is being used. 
  • CU29041349-0 Profile Picture
    CU29041349-0 112 on at
    Custom data entity not calling validateWrite()
    Andre,
    The logic basically checks if a field of data being inserted exists in an associated table. I did try to place the logic in the entity under validateWrite() and insert(), the same logic is already in the table also using validateWrite(). 
    After duplicating from the base entity, I modified the DM staging table, the collection and entity names, changed the datasource, modified the entitykey. And yes, I built and synced my project, and went so far as to rebuild and sync the models to no success. 
  • CU29041349-0 Profile Picture
    CU29041349-0 112 on at
    Custom data entity not calling validateWrite()
    Layan,
    Querying the entity, there is data returned. The collection names are unique as they are modeled against the our custom table. In troubleshooting, I added records into another legal entity (the default for my userId) and found using the URL did return those records, but not from the other legal entity I was testing with. Regardless, the validation was not triggered. 
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 4,431 User Group Leader on at
    Custom data entity not calling validateWrite()
    Hi,
     
    You must launch build with synchro and then refresh entity list through the DM parameters.
    Best regards,
    Mohamed Amine MAHMOUDI

Helpful resources

Quick Links

Contextual content recommendations & SharePoint Q&A

Instantly access relevant sales materials…

Beyond the DRA Cloud Label Printing

Explore cloud-based label printing within Dynamics 365…

HR Infrastructure Customer merge

Important considerations for HR Customer migrations…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,414 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,502 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,142

Featured topics

Product updates

Dynamics 365 release plans