D365FO – AX – X++ – Extension method data accessor examples

SourceEventParmExample
ClassPre/Post eventXppPrePostArgsGet args and parmameter values from a method that is being extended. Parm 1 = Object Parm 2 = Common
PurchCreateFromSalesOrder callingClass = args.getThis() as PurchCreateFromSalesOrder;       
Object callerObject = args.getArgNum(1) as Object;
Common callerRecord = args.getArgNum(2) as Common;
ClassPre/Post eventXppPrePostArgsClass example: SalesLineType salesLineType = args.getThis() as SalesLineType; 
FormInitializedxFormRunFormDataSource purchLine = sender.dataSource(formDataSourceStr([formname],[table]));
FormDataSourceFormDataSourceFormDataSource formDS = sender.formRun().dataSource(formDataSourceStr(EcoResProductDetailsExtended, MHSmartATPItemSettings));
MHSmartATPItemSettings smartATPItemSettings = formDS.cursor();
FormDataSource FieldFormDataObjectFormDataSource formDS = sender.datasource();
PurchLine purchLine = formDS.cursor();
FormForm ControlFormControlFormRun formRun;
FormControl formControl;
formRun = sender.formRun();
formControl = FormRun.design().controlName(formControlStr(<form name>, <control name>));
someVariable = formControl.valueStr();
FormonClickedFormControl FormRun formRun = sender.formRun();
 FormDataSource formDSSalesTable = formRun.dataSource(formDataSourceStr(SalesTable, SalesTable));
 FormDataSource formDSSalesLine = formRun.dataSource(formDataSourceStr(SalesTable, SalesLine));
       
 SalesTable salesTable = formDSSalesTable.cursor();
 SalesLine salesLine = formDSSalesLine.cursor();
FormPre/Post eventXppPrePostArgsFormRun formRun = args.getThis();
FormDataSource formDSLogisticsPostalAddress = formRun.dataSource(formDataSourceStr(LogisticsPostalAddress, LogisticsPostalAddress));
LogisticsPostalAddress logisticsPostalAddress = formDSLogisticsPostalAddress.cursor();
TableonDeleteCommonPurchLine purchLine = sender as PurchLine;
TableModified Field ValueCommonTableName itemSettings = sender as TableName;
ModifyFieldValueEventArgs fieldEvent = e as ModifyFieldValueEventArgs;

  //check to see which field was modified
  switch(fieldEvent.parmFieldName())
        {
            case fieldStr([tablename], [fieldname]):
            …do stuff
            break;
        }
TableValidateFieldValueCommon/DataEventArgsValidateFieldValueEventArgs fieldEvent = e;
boolean isValid;
PurchLine purchLine = sender as PurchLine;
       
//declare the checkFailed      
isValid = checkFailed(“some error event”);
//save the result
fieldEvent.parmValidateResult(isValid);
TablePre/Post eventXppPrePostArgsPurchLine purchLine = args.getThis() as PurchLine;

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...