Showing posts with label Data Management Framework. Show all posts
Showing posts with label Data Management Framework. Show all posts

Data Management Project Using X++

 

Data Management Project Using X++


Using the following code, you can import the file and execute the project using your x++ code.

In the code, I am making the file on runtime and uploading the file into temp storage for the demo purpose
but you can use the file uploader as per your requirement.


Code

class AD_Test
{
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        FileUploadTemporaryStorageStrategy fileUploadStrategyInstance;
        DMFDefinitionGroupEntity    definitionGroupEntityBuffer;
        DMFEntity                   dmfEntitybuffer;
        FileUploadTemporaryStorageResult result;
        SysDictClass uploadStrategyDictClassInstance;
        str entityName = 'VendVendorGroupEntity';
        System.IO.StreamWriter swriter;
        System.IO.MemoryStream   fileStream;
        DMFExecutionId executionId;
        #File



        fileStream = new System.IO.MemoryStream();
        swriter = new System.IO.StreamWriter(fileStream);
        swriter.WriteLine("VENDORGROUPID,DESCRIPTION");
        swriter.WriteLine(strFmt("%1,%2",'Ex-VendGroup','Example Vendor group'));
        swriter.Flush();

        uploadStrategyDictClassInstance = new SysDictClass(className2Id('FileUploadTemporaryStorageStrategy'));
        fileUploadStrategyInstance = uploadStrategyDictClassInstance.makeObject() as FileUploadTemporaryStorageStrategy;
        result = fileUploadStrategyInstance.uploadFile(fileStream, 'VendorsGroups.csv');
     
        fileStream.Dispose();

        CodeAccessPermission::revertAssert();

        executionId = DMFUtil::setupNewExecution('ImportVendorGroup');

        select firstonly  Entity from definitionGroupEntityBuffer exists join dmfEntitybuffer
            where definitionGroupEntityBuffer.DefinitionGroup == 'ImportVendorGroup' &&
                dmfEntitybuffer.EntityName == definitionGroupEntityBuffer.Entity &&
            dmfEntitybuffer.TargetEntity == entityName ;

       
        DMFDefinitionGroupExecution executionBuffer = DMFDefinitionGroupExecution::find('ImportVendorGroup', definitionGroupEntityBuffer.Entity, executionId, true);
        ttsbegin;
        executionBuffer.FilePath = result.getFileId();
        executionBuffer.IsTransformed = NoYes::Yes;
        executionBuffer.update();
        ttscommit;

        DMFQuickImportExport::doPGImport('ImportVendorGroup', executionId, true);
    }

}

Skip/Bypass validation in Data Entity Import – D365FO

 


Skip/Bypass validation in Data Entity Import – D365FO


I had a scenario where I need to create the Tax Exempt Number dynamically when importing Vendors' data.

For instance, if the given VatNum does not exist in the input data, the system should bypass the validation and create the vendor without any error. 


So, how do we incorporate this validation? Using the COC method of persistEntity.

public void persistEntity(DataEntityRuntimeContext _entityCtx)
{   
    
        next persistEntity(_entityCtx);
     this.skipDataSourceValidateField(fieldNum(VendVendorsV2,
     VatNum),true);
    
}

The 'Dimension Legal Entity Context field' must be entered

 

The 'Dimension Legal Entity Context field' must be entered, when the extended data type is 'DimensionDynamicAccount' or 'DimensionDynamicDefaultAccount'.


Today, I was getting the following errors while creating one data entity, after searching over google I realized that two field-level properties on my entity should be filled.

  • DimensionLegalEntityContextField
  • DynamicDimensionEnumerationField

Path: [AxDataEntityView/ABCDEntity/Fields/LedgerDimension/DimensionLegalEntityContextField]:The 'Dimension Legal Entity Context field' must be entered, when the extended data type is 'DimensionDynamicAccount' or 'DimensionDynamicDefaultAccount'.

Path: [AxDataEntityView/ABCDEntity/Fields/LedgerDimension/DynamicDimensionEnumerationField]:The 'Dynamic Dimension Enumeration Field' must be entered, when the extended data type is 'DimensionDynamicAccount' or 'DimensionDynamicDefaultAccount'.




Solution


DimensionLegalEntityContextField

This field property should be filled with Data Area Id, for reference, I also pasted the screenshot.


DynamicDimensionEnumerationField

This field property should be filled with either 'DimensionDynamicAccount' or 'DimensionDynamicDefaultAccount for reference, I also pasted the screenshot.

Options:
  1. DimensionDynamicAccount
  2. DimensionDynamicDefaultAccount



Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...