Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / How to skip validation...
Finance forum

How to skip validation in data entity

(0) ShareShare
ReportReport
Posted on by 2,015

Hi Techies,

I have created a new data entity. While importing a data, in staging table it throws below validation error -

Results. insert not allowed for field 'Transaction ID(TransId)'
Results. Validations failed

Datasource - ProjOnAccTrans.

I tried writing below code to skip this validation in multiple methods, but it won't work until I skip this validation from 'Modify target mapping' form.

 this.skipDataSourceValidateField(fieldNum(ProjOnAccTransEntity, TransId), true);


 Is there any other feasible way to do this via code?

Any response is appreciated.

Thanks,

Sangram

  • Reliable Profile Picture
    Reliable 2,015 on at
    RE: How to skip validation in data entity

    Hi Andre, I changed the property from Auto to Yes from entity level and tested, but it didn't work, then I switched to debug the code again to trace the exact code to share with Ievgen for solution, and in this run - the execution ran from DMFEntityBase ->_target.insert() method(Line 2312) to persistEntity() method (Which I was waiting for) that I have written in data entity to skip this validation and it works!

    I am not sure why it wasn't working initially, I have cleaned everything and kept only persistEntity() method, this might have worked.

    Thanks Andre and Ievgen for the solutions and the time, your answers are always helpful.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,359 Super User 2024 Season 2 on at
    RE: How to skip validation in data entity

    Hi Sangram,

    You can check these properties on the fields of the data entity. Don't change this property on the original (target) table.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to skip validation in data entity

    You don't need to change them, all you need is to skip validation, that's exactly why skipDataSourceValidateField method is available.  And you did not tell us where this error is coming from, did you try to debug and investigate?

  • Reliable Profile Picture
    Reliable 2,015 on at
    RE: How to skip validation in data entity

    Hi Andre,

    AllowEdit and AllowEditOnCreate are set to 'No' at table properties(ProjOnAccTrans) as you said. But this is a standard table, what is possible way to change this property.

    Thanks,

    Sangram

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to skip validation in data entity

    Where exactly are you getting this error?

  • Reliable Profile Picture
    Reliable 2,015 on at
    RE: How to skip validation in data entity

    Hi Andre,

    I will check this and update.

    Thanks,

    Sangram

  • Reliable Profile Picture
    Reliable 2,015 on at
    RE: How to skip validation in data entity

    Yes i tried in persistEntity method as well Ievgen, but the error is occurring before hitting this method itself.

    Thanks,

    Sangram

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: How to skip validation in data entity

    This used to work:

    public void persistEntity(DataEntityRuntimeContext _entityCtx)
    {
        this.skipDataSourceValidateField(fieldNum(ProjOnAccTransEntity, TransId), true);
    
        super(_entityCtx);
    }


    Try!

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,359 Super User 2024 Season 2 on at
    RE: How to skip validation in data entity

    Hi Sangram,

    Initially, it looks like the field has been set to not allow edit. What is the property value on the datasource field? If it is set to No or Auto, try the option Yes.

    Did you also perform a metadata search to see where Microsoft did use this command in their own application?

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

Announcing Category Subscriptions!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans