This post describes the steps and code required to create an event handler for SalesTable form.
1. Create a class
class salesTableForm_EventHandler
{
}
2. Open SalesTable form Events node.
3. Right click the event and Copy Event Handler Method
4. Paste the code in the class you created.
[FormEventHandler(formStr(SalesTableListPage), FormEventType::Activated)]
public static void SalesTableListPage_OnActivated(xFormRun sender, FormEventArgs e)
{
XMA_SalesOrderLoqateAddressList_Table addressList;
FormDataSource salesTable_ds = sender.dataSource(formDataSourceStr(SalesTable, SalesTable));
FormControl buttonUpdateConfirmation = sender.control(sender.controlId('buttonUpdateConfirmation'));
SalesTable salesTable = salesTable_ds.cursor();
if (salesTable.deliveryAddress == NoYes::Yes)
{
buttonUpdateConfirmation.visible(true);
}
else
{
buttonUpdateConfirmation.visible(false);
}
}
5. Right click the form control and copy Event Handler method
[FormControlEventHandler(formControlStr(SalesTable, CopyOfReferenceGroup), FormControlEventType::Modified)]
public static void CopyOfReferenceGroup_OnModified(FormControl sender, FormControlEventArgs e)
{
FormDataSource salesTable_ds = sender.formRun().dataSource(formDataSourceStr(SalesTable, SalesTable));
FormControl buttonUpdateConfirmation = sender.formRun().design().controlName('buttonUpdateConfirmation');
SalesTable salesTable = salesTable_ds.cursor();
SalesTable salesTableOrig = salesTable.orig();
if (salesTable.deliveryAddress().RecId != salesTableOrig.deliveryAddress().RecId)
{
Error("Error");
ttsbegin;
salesTable.deliveryAddress = 555665544;
salesTable.doUpdate();
ttscommit;
sender.formRun().reload();
buttonUpdateConfirmation.visible(false);
}
}
Regards,
Arun S Keerthi
No comments:
Post a Comment