How to extend Form datasource method X++
Views (724)
Hi guys,
This blog will be useful in those scenarios where in standard MS Form datasource methods (init, write, validateWrite, active, selectionChanged etc) will be required to further extend the standard functionality.
Requirement:
I came across a requirement on which I had to disable the standard MS field on the basis of a true value on custom boolean field. If custom flag field contains true value then target field "Allow reservation" on the return sales order line should be disabled as a result of focus set on that selected return sales order line.
Solution:
Right click on the Form datasource active method and then click create an extension to create an extension class.
[ExtensionOf(formDataSourceStr(ReturnTable, SalesLine))]
final class DemoReturnTableSalesLineFrm_Extension
{
int active()
{
int ret = next active();
SalesLine salesLine = this.cursor();
SalesTable salesTable = SalesTable::find(salesLine.SalesId);
FormRun formRun = this.formRun();
if(salesTable.DemoPriceAdjustment)
{
formRun.control(formRun.controlId(formControlStr(ReturnTable, return_ReturnAllowReservation))).enabled(false);
}
return ret;
}
}
Comments
-
How to extend Form datasource method X++I'm sorry to say this, but I tried that approach, and I did not get that option displaying in the context menu after right-clicking on the target datasource form active method.The only option available is to manually create the class and not forgetting to add the following:
[ExtensionOf(formDataSourceStr(SalesTable, SalesTable))] final class SalesTable_Extension
Then extend the active method and do not forget chain wrapping the data method:next active( )
*This post is locked for comments