Posts

D365F&O - X++ - set display method from table extension in form control

Image
 1- Right click on the table and click "create extension" and write your display method. [ExtensionOf(tableStr(CustTrans))] final class CustTransTable_Extension {     public display CustGroupId getCustGroup()     {         return CustTable::find(this.AccountNum).CustGroup;     } } 2- Go to the control where you want to set the display method set display method as below

D365F&O - X++ - Best Practice Warning BP Rule: [BPErrorUnknownLabel]: Path:

To resolve the following error:  Path: [dynamics://Table/SalesTable/Field2]:Unknown label ‘@ZILabel:NewLabel’. Legacy labels (such as the label id @SYS12345) are case insensitive and modern labels (such as ‘MyLabelId’ in @MyLabelFile:MyLabelId) are case sensitive. Use upper casing when referring to legacy labels and exact casing for modern labels.  use  literalStr()  before the custom label. info(literalStr(" @ZILabel:NewLabel " ) ) ;

D365F&O - X++ - Get form control in coc method in form extension

[ExtensionOf(formControlStr(SalesUpdateRemain, ButtonCancelLine))] final class SalesUpdateRemainButtonCancel_Extension {     void clicked()     {         next clicked();         #define.SalesPhysical('remainSalesPhysical')         FormControl formButtonControl = any2Object(this) as FormControl;         FormRealControl remainSalesPhysicalControl = formButtonControl.formRun(). control(formButtonControl.formRun().controlId(             (formcontrolstr(SalesUpdateRemain, remainSalesPhysical )) ));                 remainSalesPhysicalControl.realValue(50 0 );     } }

D365F&O - X++ - Best Practice Warning [BPUnusedStrFmtArgument]:The placeholder ‘%1’ to strFmt is not used in the format string.

 T o remove the BP warning add  literalStr()  for label string validation in your code where you have used %1 in your label string. error( strfmt( literalStr( "@MyLabel:LabelCust" ), CustTable.InvoiceId) ) ;

D365F&O - X++ - Get datasource in modified method COC in form control extension

[ExtensionOf(formControlStr(CustFreeInvoice, OrderAccount))] final class CustFreeInvoiceOrderAccount_Extension {     public boolean modified()     {         Boolean ret = next modified();         FormControl formControl = any2Object(this) as FormControl;         FormDataSource custInvoiceTable_ds =                formControl.formRun().dataSource(tableStr(CustInvoiceTable));         custInvoiceTable custInvoiceTable = custInvoiceTable_ds.cursor();                 if (CustInvoiceTable.RecId == 0 )         {             ret = true ;         }         custInvoiceTable_ds.research(true);         return ret;     } }  

D365F&O - X++ - create modified method coc of form control in form extension

 1- Right click on form and click "create extension". [ExtensionOf(formControlStr(CustFreeInvoice, OrderAccount))] final class CustFreeInvoiceOrderAccount_Extension {     public boolean modified()     {         Boolean ret = next modified();                   FormDataSource custInvoiceTable_ds = this.formRun().dataSource(tableStr(CustInvoiceTable));         custInvoiceTable custInvoiceTable = custInvoiceTable_ds.cursor();                if (CustInvoiceTable.RecId == 0 )         {             CustInvoiceTable.write();         }         custInvoiceTable_ds.research(true);         return ret;     } }

D365F&O - X++ - Get formdatasource in init method in form extension

 public void init() {     next init();          FormDataSource SalesTable_ds = this.dataSource(formDataSourceStr(        CustTrans, SalesTable));     SalesTable_ds.queryBuildDataSource().clearLinks();     SalesTable_ds.queryBuildDataSource().addLink(fieldNum(CustInvoiceJour, SalesId),     fieldNum(SalesTable, SalesId)); }