Tuesday, February 26, 2019

Auto fill segmented control on form in D365FO


 public void setSegmentedDefaults()
    {
        DimensionStorage                    dimensionStorage;
        DimensionStorageSegment             segment;   
        DimensionAttribute                  dimensionAttribute;
        DimensionAttributeValue             dimensionAttributeValue;
        ;

        dimensionStorage = DimensionStorage::findById(this.LedgerDimension);

        dimensionAttribute = DimensionAttribute::findByName('BusinessUnit');
        dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimensionAttribute, '002', false, true);
        segment = DimensionStorageSegment::constructFromValue('002', dimensionAttributeValue);
        dimensionStorage.setSegmentForHierarchy(1, 2,segment);
        this.LedgerDimension = dimensionStorage.getSavedComboRecId();

        dimensionAttribute = DimensionAttribute::findByName('Department');
        dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimensionAttribute, '024', false, true);
        segment = DimensionStorageSegment::constructFromValue('024', dimensionAttributeValue);
        dimensionStorage.setSegmentForHierarchy(1, 3,segment);
        this.LedgerDimension = dimensionStorage.getSavedComboRecId();
                     
    }

Tuesday, February 19, 2019

Call stack window missing in Visual Studio D365FO


It is very crucial to have a call stack window to understand the flow of the code. To enable call stack follow below points.

1. Open visual studio and put a breakpoint.
2. Run the code and wait for the debugger to hit the breakpoint.
3. Go to Debug->windows->Call stack


Monday, February 4, 2019

How to create Retail product category in D365FO using X++


Guys we can use below code to create the retail product category using X++

 EcoResCategory ecoResCatImport

 ecoResCatImport.clear();
 ecoResCatImport.initValue();
 ecoResCatImport.initFromParent(EcoResCategory::findByName('HAL',ecoResCategory.CategoryHierarchy);
ecoResCatImport.Code = 'Test_categoryimport';
 ecoResCatImport.Name = 'Test_Categoryimport';
 ecoResCatImport.addToHierarchy();

Getting Query validation failed-FF004 error in D365FO import job

Once I was importing a package with products V2 entity. I was getting an error "Query validation failed-FF004"  the reason is the data source format in package is set to accept the the row delemeter different from what is set in D365FO.

To resolve this go to

Data Management -> configure data Source -> VerticleBarSaperated(select the source which is mentioned in the manifest file of the packge, in my case it was Vertical Bar Saperated)



Just change the Row delimiter to {LF} form {CRLF} save and import again.