[FormDataSourceEventHandler(formDataSourceStr(PurchReqTable, PurchReqTable), FormDataSourceEventType::Activated)]
public static void PurchReqTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
FormDataSource purchReqTable_ds = sender.formRun().dataSource(formDataSourceStr(PurchReqTable, PurchReqTable));
FormDataSource purchReqLine_ds = sender.formRun().dataSource(formDataSourceStr(PurchReqTable, PurchReqLine));
FormDataSource inventDim_ds = sender.formRun().dataSource(formDataSourceStr(PurchReqTable, InventDim));
FormDataSource businessJustificationHeader_ds = sender.formRun().dataSource(formDataSourceStr(PurchReqTable, BusinessJustificationHeader));
FormDataSource businessJustificationLine_ds = sender.formRun().dataSource(formDataSourceStr(PurchReqTable, BusinessJustificationLine));
FormDataSource logisticsPostalAddressLine_ds = sender.formRun().dataSource(formDataSourceStr(PurchReqTable, LogisticsPostalAddressLine));
FormDataSource purchReqLineKMCollection_ds = sender.formRun().dataSource(formDataSourceStr(PurchReqTable, PurchReqLineKMCollection));
FormDataSource purchReqExternalSource_ds = sender.formRun().dataSource(formDataSourceStr(PurchReqTable, PurchReqExternalSource));
FormDataSource purchReqLineTaxExtensionIN_ds = sender.formRun().dataSource(formDataSourceStr(PurchReqTable, PurchReqLineTaxExtensionIN));
PurchReqTable purchReqTable = purchReqTable_ds.cursor();
if(purchReqTable.myCondition())
{
purchReqTable_ds.allowEdit(false);
purchReqLine_ds.allowEdit(false);
inventDim_ds.allowEdit(false);
businessJustificationHeader_ds.allowEdit(false);
businessJustificationLine_ds.allowEdit(false);
logisticsPostalAddressLine_ds.allowEdit(false);
purchReqLineKMCollection_ds.allowEdit(false);
purchReqExternalSource_ds.allowEdit(false);
purchReqLineTaxExtensionIN_ds.allowEdit(false);
}
}
Hello,
It seems you're using allowEdit(false)
based on certain conditions in your form's data source, likely through an event handler. Instead of relying on event handlers, you can simplify your approach by directly overriding the form methods.
For example, you can set the edit permission like this:
yourdatasource_ds.allowEdit(false);
Or, for a specific field, you can use:
yourdatasource_ds.object(fieldNum(datasourcetable, field)).allowEdit(false);
This approach reduces complexity and keeps your code organized. For further insights, you may find this blog helpful: Enable/AllowEdit of DataSource Field.
If you have any questions or need more information, feel free to ask!
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,435 Super User 2024 Season 2
Martin Dráb 228,317 Most Valuable Professional
nmaenpaa 101,148