On DataSource on form CustTable
class CustTableFormEventHandler
{
[FormDataSourceEventHandler(formDataSourceStr(CustTable, CustTable), FormDataSourceEventType::Activated)]
public static void CustTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
CustTable custTable = sender.cursor();
FormDataSource custTable_ds = sender.formRun().dataSource("CustTable");
FormRun element = sender.formRun() as FormRun;
FormControl myNewButton = element.design(0).controlName("MyNewButton");
myNewButton.enabled(false);
}
}
On method on form SalesEditLines
-- Method closeOk
[PostHandlerFor(formStr(SalesEditLines), formMethodStr(SalesEditLines, closeOk))]
public static void SalesEditLines_Post_closeOk(XppPrePostArgs args)
{
FormRun sender = args.getThis();
SalesParmTable salesParmTable;
SalesTable salesTable;
SalesDocumentStatus docStatus;
;
salesParmTable = sender.dataSource(formdatasourcestr(SalesEditLines, SalesParmTable)).cursor();
salesTable = SalesTable::find(salesParmTable.SalesId);
docStatus = salesParmTable.documentStatus();
if(docStatus != DocumentStatus::PackingSlip)
{
return;
}
//Som source codes in here
}
-- Event Closing
[FormEventHandler(formStr(SalesEditLines), FormEventType::Closing)]
public static void SalesEditLines_OnClosing(xFormRun sender, FormEventArgs e)
{
FormDataSource datasource_ds = sender.dataSource(formDataSourceStr(SalesEditLines, SalesLines));
SalesLine buffTable = datasource_ds.cursor();
}
***
[FormEventHandler(formStr(TSExtensionInstanceTest), FormEventType::Initialized)]
public static void TSExtensionInstanceTest_OnInitialized(xFormRun sender, FormEventArgs e)
{
FormRun formRun = sender as FormRun;
TSExtensionInstanceTestHandler extensionInstance = formRun.getExtensionInstance(classStr(TSExtensionInstanceTestHandler));
extensionInstance.init();
}
On method Modified of field in datasource TrvRequisitionLine on form
[FormDataFieldEventHandler(formDataFieldStr(TrvRequisition, TrvRequisitionLine, Category),
FormDataFieldEventType::Modified)]
public static void Category_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
FormDataSource trvRequisitionLine_DS;
TrvRequisitionTable requisitionTable;
TrvRequisitionLine requisitionLine;
ormReferenceGroupControl formControlLocationDetail;
//Get datasouce
trvRequisitionLine_DS = sender.datasource();
//Get the formRun
formRun = TrvRequisitionLine_DS.formRun();
//Get currently selected record
requisitionLine = trvRequisitionLine_DS.cursor();
//Get any other datasouce you want form form with help of relation
requisitionTable = TrvRequisitionTable::find(requisitionLine.TrvRequisitionTable);
//Set any value of record field value based on your calculation
requisitionLine.AccountingCurrencyAmount = 0;//TODO::Some calculations you need to do and set value of amount
//Change state of any control on form
formControlLocationDetail =
formRun.design().controlName(formControlStr(TrvRequisition,PerdiemTrvLocations_Details));
formControlLocationDetail.mandatory(false);
formControlLocationDetail.enabled(false);
}
On method Clicked of button on form
[FormControlEventHandler(formControlStr(TSExtensionInstanceTest, Counter), FormControlEventType::Clicked)]
public static void Toggle_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun element = sender.formRun() as FormRun;
FormControl myNewButton = element.design(0).controlName("MyNewButton");
myNewButton.enabled(false);
}
No comments:
Post a Comment