Sunday, April 9, 2023

Adding a new Financial Dimension tab in purchase requisition form in D365 FO

Adding a new Financial Dimension tab in the purchase requisition form in D365 FO.


 For the Purchase requisition table "Save Data per company" is set No.

So we need to add some extra code. For the Line table in standard, they have developed. I took the reference from there.

Step 1: Add dimension field in Table. Copy from the vendTable. The EDT should be extended with LedgerDimensionValueSet




Step 2: Add dimension control in the form.


In form init method.

	[ExtensionOf(formStr(PurchReqTable))]
	final class PurchReqTable_Extension
	{
	    public void init()
	    {
	        next init();

	        DimensionEntryControl   fCC = DimensionEntryControl as DimensionEntryControl;

	        fCC.parmValidateBlockedForManualEntry(true);     
	    } 
	}


DataSource Active method.

[FormDataSourceEventHandler(formDataSourceStr(PurchReqTable, PurchReqTable), FormDataSourceEventType::Activated)]
public static void PurchReqTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
    PurchReqTable    		purchReqTable   =   sender.cursor();
    DimensionEntryControl    	fCC 		=   sender.formRun().design().controlName("DimensionEntryControl") as DimensionEntryControl;

    fCC.parmCompany(curExt());
    fCC.reactivate();
}


TabPage Active method:

[FormControlEventHandler(formControlStr(PurchReqTable, HeaderTabFinancialDimensions), FormControlEventType::PageActivated)]
public static void HeaderTabFinancialDimensions_OnPageActivated(FormControl sender, FormControlEventArgs e)
{
    PurchReqTable    		purchReqTable   = sender.formRun().dataSource(FormDataSourcestr(PurchReqTable, purchReqTable)).cursor();
    DimensionEntryControl    	fCC 		= sender.formRun().design().controlName("DimensionEntryControl") as DimensionEntryControl;

    fCC.parmCompany(curExt());
    fCC.reactivate();
}


Output:





No comments:

Post a Comment