62) Skip/Bypass validation in DataEntity Import – D365FO

 I had a scenario where I need to create the State/County dynamically when importing Customer data.

For instance, if the given County/State doesnot exist in the input data, the system should bypass the validation and create it. This will be applied if the State/County is disabled in Address Parameters.

I tried the import from POSTMAN with the standard CustCustomerV3 entity and ended up with the following error.

So, how do we incorporate this validation. Using Persist method

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public void persistEntity(DataEntityRuntimeContext _entityCtx)
{   
    if(LogisticsAddressParameters::find().ValidateState == NoYes::No)
    {       
        
      this.skipDataSourceValidateField(fieldNum(LogisticsPostalAddressBaseEntity,
      State), true);
    }
     
    if(LogisticsAddressParameters::find().ValidateCounty == NoYes::No)
    {       
     this.skipDataSourceValidateField(fieldNum(LogisticsPostalAddressBaseEntity,
     County),true);
    }
}

Build the changes and test the above data. This time, the validation will be skipped.

Note:

The above change would skip only the validation . Creation of the new data has to handled in the insertEntityDataSource.

Comments

Popular posts from this blog

Customization on Sales invoice Report in D365 F&O

75) COC - Create a coc of the table modified method

46) D365 FO: SHAREPOINT FILE UPLOAD USING X++