Form Control Event Handler Methods in Dynamics 365

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
Debunking: Dynamics CRM Destination – How Text Lookup Works
When we want to push data to Dataverse/Dynamics CRM using SSIS – KingswaySoft, usually there are relationships (lookup) that we need to ...
Understanding Activity Party Types in Dynamics 365 CE
Dynamics 365 Customer Engagement features 11 unique activity party types, identified by specific integer values in the ActivityParty.Participa...
Debunking: KingswaySoft Dynamics CRM Source- Output Timezone
Hi! I’m back after so a long hiatus (probably I’ll write the reason for this later 🤣). As [lazy] Developers, we’re most lik...
How to configure donotreply email using Shared mailboxes in Dynamics 365 CE?
This article explains how to create and configure a Shared Mailbox in Microsoft 365 for sending emails to users in Dynamics 365 CE. It details...
Enhancing Knowledge Retrieval with Microsoft Copilot Agents in Dynamics CRM and SharePoint
Studies show that 70% of employees spend unnecessary time searching for information across multiple systems, leading to productivity losses an...
{How to} become MCT Microsoft Certified Trainer on Microsoft Dynamics 365 Customer Engagement step by step instructions
Hello Everyone,Today i am going to share guidelines on becoming Microsoft Certified Trainer on Microsoft Dynamics 365 Customer Engagement or P...
Default Value vs. Current Value in Dynamics 365 CE: Key Differences
In Dynamics 365 CE (Customer Engagement), environment variables are used to manage configuration settings for solutions. When dealing with env...
How to Write and Understand a Dynamics CRM Plugin
Here’s a sample plugin code in Dynamics CRM written in C#, along with a detailed explanation of each line. This plugin will update the "...
Dynamics 365 CE Solution Import Failed in Azure DevOps Pipelines
Got the below error while importing Dynamics CRM Solution via Azure DevOps Pipeline. 2024-12-18T23:14:20.4630775Z ]2024-12-18T23:14:20.74...
Exploring the Differences: Managed vs. Unmanaged Solutions in Dynamics CRM/Dataverse
In Dynamics CRM/Dataverse, solutions are central to Application Lifecycle Management (ALM), providing a structured way to manage, package, and...