Enable/Disable form control on activation of form D365 X++
Form : SalesQuotationListPage
DataSource : DH_SalesQuote
Event : Activated
[FormDataSourceEventHandler(formDataSourceStr(SalesQuotationListPage, DH_SalesQuote), FormDataSourceEventType::Activated)]
public static void DH_SalesQuote_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
FormRun fromRunLoc;
FormDataSource formDataSourceLoc;
DH_SalesQuote SalesQuote;
fromRunLoc = sender.formRun();
formDataSourceLoc = sender.formRun().dataSource("DH_SalesQuote");
SalesQuote = formDataSourceLoc.cursor();
if (SalesQuote.DH_DocumentWorkflowState == DH_DocumentWorkflowState::Completed)
{
fromRunLoc.control(fromRunLoc.controlId("FollowupStatus")).enabled(true);
fromRunLoc.control(fromRunLoc.controlId("ButtonUpdateConfirmation")).enabled(true);
fromRunLoc.control(fromRunLoc.controlId("UpdateQuotation")).enabled(true);
fromRunLoc.control(fromRunLoc.controlId("Process")).enabled(true);
}
else
{
fromRunLoc.control(fromRunLoc.controlId("FollowupStatus")).enabled(false);
fromRunLoc.control(fromRunLoc.controlId("ButtonUpdateConfirmation")).enabled(false);
fromRunLoc.control(fromRunLoc.controlId("UpdateQuotation")).enabled(false);
fromRunLoc.control(fromRunLoc.controlId("Process")).enabled(false);
}
}
DataSource : DH_SalesQuote
Event : Activated
[FormDataSourceEventHandler(formDataSourceStr(SalesQuotationListPage, DH_SalesQuote), FormDataSourceEventType::Activated)]
public static void DH_SalesQuote_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
FormRun fromRunLoc;
FormDataSource formDataSourceLoc;
DH_SalesQuote SalesQuote;
fromRunLoc = sender.formRun();
formDataSourceLoc = sender.formRun().dataSource("DH_SalesQuote");
SalesQuote = formDataSourceLoc.cursor();
if (SalesQuote.DH_DocumentWorkflowState == DH_DocumentWorkflowState::Completed)
{
fromRunLoc.control(fromRunLoc.controlId("FollowupStatus")).enabled(true);
fromRunLoc.control(fromRunLoc.controlId("ButtonUpdateConfirmation")).enabled(true);
fromRunLoc.control(fromRunLoc.controlId("UpdateQuotation")).enabled(true);
fromRunLoc.control(fromRunLoc.controlId("Process")).enabled(true);
}
else
{
fromRunLoc.control(fromRunLoc.controlId("FollowupStatus")).enabled(false);
fromRunLoc.control(fromRunLoc.controlId("ButtonUpdateConfirmation")).enabled(false);
fromRunLoc.control(fromRunLoc.controlId("UpdateQuotation")).enabled(false);
fromRunLoc.control(fromRunLoc.controlId("Process")).enabled(false);
}
}
Comments
Post a Comment