Monday, May 13, 2019

Vendor invoice add Requester to the hierarchy workflow in D365FO

I had a request for a development where there was a need to have a hierarchical workflow approval process in Vendor invoice. The issue was the requestor was not available in the workflow setup. To fix this I had the done the below changes.


 Create an extension for table VendInvoiceInfoTable and add new field Originator in table VendInvoiceInfoTable.




 Make sure the EDT for this new field is PurchReqRequesterRefRecId



 Extend query VendInvoiceDocument and add the new field created in table VendInvoiceInfoTable  to this query


Add the field in the form VendEditInvoice


In workflow configuration, you will find requestor, now when invoicing the PO just enter the requester user Id. 

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();