Tuesday, August 13, 2019

How to add an Entity in Data Project through code (X++)

         DMFDefinitionGroupEntity   addEntity;

        if (DMFQuickImportExportFormHelper::validateEntity(_entityName, _sourceName, DMFOperationType::Export))
        {
            ttsbegin;
            addEntity.clear();
            addEntity.initValue();
            addEntity.DefaultRefreshType = DMFRefreshType::IncrementalPush;
            addEntity.DefinitionGroup = _definitionGroup;
            addEntity.Entity = _entityName;
            addEntity.EntityXMLName = _targetEntity;
            addEntity.SkipStaging = NoYes::Yes;
            addEntity.source = _sourceName;
            addEntity.validationStatus = NoYesError::Yes;
            addEntity.ExecutionUnit = NoYes::Yes;
            addEntity.LevelInExecutionUnit = NoYes::Yes;
            addEntity.insert();

            //Generate mapping
            DMFXmlGeneration::generateMappingV2(addEntity);
            ttscommit;
                       
           
        }

Variables -

  1. _entityName - Name of the Entity
  2. _SourceName - Source Data Format (like BYOD, Excel)
  3. _definitionGroup - Definition Group Name (or Data Project Name)

#DataEntities #X++ #D365F&O #DMF

Thursday, June 27, 2019

How to get Azure Blob URL in D365FO


When we are exporting data in Excel or any other format using DIXF, file gets uploaded in Azure Blob and if you need that azure blob URL you can get using below code -

DMFEntityExportDetails      exportDetails;

you can find exportDetails table buffer by passing DMF definition group and entity name. 

str downloadUrl = DMFDataPopulation::getAzureBlobReadUrl(str2Guid(exportDetails.SampleFilePath));











#D365F&O #DIXF #DMF 

Thursday, April 4, 2019

How to get the primary table from Data Entity in D365F&O

Overview - How to get the primary table from an entity in D365F&O

 public static TableName getPrimaryTable(TableName _tableName)
    {
        TableName                       tableName;
        Query                               q;
        QueryBuildDataSource   dataSource;

        DictDataEntity dictEntity = new  DictDataEntity(tableName2Id(_tableName));
        if (dictEntity)
        {
            q = dictEntity.query();
            if (q.dataSourceCount() >= 1)
            {
                dataSource = q.dataSourceNo(1);
                if (dataSource)
                {
                    tableName = tableId2Name(dataSource.table());
                }
            }
        }
         
        return tableName;
    }

And if we need all tables from the data entity, we can loop the data source count.

#D365F&O #AX #Entities