Form Control Event Handler Methods in Dynamics 365
![Form Control Event Handler Methods in Dynamics 365 Form Control Event Handler Methods in Dynamics 365](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_UvNhZQhZf10Swrmy9suBbNlOyJvVBJSpSXS62LQKOuE8PUpLiJOUydVBgjnD47eNgWk0klg3NnS7AZ6TLwyxXl9n2e7hE7N3l2Dw8_vcd-jDzc26knYCFpF8u9WxXK0hAePL6z1HGtA/w1200-h630-p-k-no-nu/1.png)
For example, In Dynamics 365 for Operations you can react to the OnClicked event by copying the event handler method for the event and pasting the method into a class.
Create new Class and paste below code in it for SalesEditLines EventHandlers
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(SalesEditLines, OK), FormControlEventType::Clicked)]
public static void OK_OnClicked(FormControl sender, FormControlEventArgs e)
{
Args args = new Args();
FormCommandButtonControl callerButton = sender as FormCommandButtonControl; //Retrieves the button that we're reacting to
FormRun form = callerButton.formRun(); //Gets the running SalesEditLines form
//Get the salesId that was selected in the SalesEditLines form
FormDataSource salesParmTable_ds = form.dataSource(formDataSourceStr(SalesEditLines, SalesParmTable)) as FormDataSource;
SalesParmTable salesParmTable = salesParmTable_ds.cursor();
SalesTable salesTable=salesParmTable.salesTable();
if(salesTable.SalesStatus==SalesStatus::Invoiced)
{
//Any Action
}
}
Reference
Reference
Another Sample for OnModified of check box control - AllowEdit text box control based on checkbox selection
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(EcoResProductDetailsExtended, Other_CatchWeight), FormControlEventType::Modified)]
public static void Other_CatchWeight_OnModified(FormControl sender, FormControlEventArgs e)
{
FormCheckBoxControl callerButton = sender as FormCheckBoxControl ; //Retrieves the button that we're reacting to
FormRun element = callerButton.formRun();
FormControl catchweightMultipleToSubProject = element.design(0).controlName("Other_CatchweightMultiple");
if(callerButton.checked())
{
catchweightMultipleToSubProject.allowEdit(true);
}
else
{
catchweightMultipleToSubProject.allowEdit(false);
}
}
On Look Up Event for String Control in the form
[FormControlEventHandler(formControlStr(VendBankAccounts, PartyPaymLocationName), FormControlEventType::Lookup)]
public static void PartyPaymLocationName_OnLookup(FormControl sender, FormControlEventArgs e)
{
FormControl callerStr = sender as FormControl; //Retrieves the string that we're reacting to
FormRun form = callerStr.formRun(); //Gets the running VendBankAccounts form
FormDataSource vendBankAccount_ds = form.dataSource(formDataSourceStr(VendBankAccounts, VendBankAccount)) as FormDataSource;
VendBankAccount vendBankAccount = vendBankAccount_ds.cursor();
vendBankAccount.vendPartyPaymLookup(callerStr );
}
Creating License Plate at Item Arrival line creation while Enter non-existing Liecense Plate
public static void InventoryDimensionsGrid_LicensePlateId_OnEnter(FormControl sender, FormControlEventArgs e)
{
FormControl callerStr = sender as FormControl; //Retrieves the string that we're reacting to
FormRun form = callerStr.formRun(); //Gets the running form
FormStringControl InventoryDimensionsGrid_LicensePlateId = form.design(0).controlName("InventoryDimensionsGrid_LicensePlateId");
if(InventoryDimensionsGrid_LicensePlateId.text())
{
WHSLicensePlate::createLicensePlate(InventoryDimensionsGrid_LicensePlateId.text());
}
}
//True parameter append the text but false removes existing text and paste new text
Published on:
Learn moreRelated posts
Web resource method does not exist in Dynamics 365 CE
Got the below error while working on Onload of Account record JavaScript in Microsoft Dynamics 365 CE. Script Error One of the scripts for thi...
How to get Environment Variable Value in Dynamics 365 CE using JavaScript?
We might have got a scenario to use the Environment Variable Value in the JavaScript in Dynamics 365 CE. In this article, will explain about r...
Enhancing Business Efficiency with Dynamics 365 CE/CRM AI Capabilities
Artificial intelligence (AI) is a vital catalyst for business transformations in this digital era. A leading player in this revolution
Interview Questions and Answers Dynamics 365 CE and Power Platform – Ultimate Guide
In today's business landscape, Dynamics 365 Customer Engagement (CE) and the Power Platform have emerged as game-changing tools that have tran...
Back to Basics # 72: Limit Special Characters Using a Webresource in Dynamics CRM
Recently we got a requirement to restrict user to enter special characters. Step 1 : Use the below method for restricting special characters S...
20 Most commonly used JavaScript Scenarios with Sample code Snippet in Form Script Dataverse/ Dynamics 365 CE
JavaScript is a powerful tool for developers working with Dataverse (formerly known as Common Data Service) and Dynamics 365 Customer Engageme...
New and Retired Microsoft Dynamics 365 Certifications
Microsoft has recently shared updates regarding new and retired certifications for Microsoft Dynamics 365. This post provides an overview of t...
Embed a Power BI Report as a System Dashboard in Dynamics 365 CE Using Environment Variables
Integrating Power BI with Dynamics 365 CE can elevate your decision-making processes by providing seamless access to actionable insights. This...
How to amplify contact centers and field service operations with AI
In this video, Jeff Comstock, Corporate Vice President of Dynamics 365 Customer Service, discusses the transformative power of Copilot in enha...
Decrement field value automatically using workflow in dataverse or dynamics 365
In Dataverse (formerly known as Common Data Service) or Dynamics 365, you can automate the decrementing of a field value using workflows. With...