In Dynamics 365, quick create forms are a convenient way to rapidly add records. However, sometimes you might want to restrict this functionality for certain applications to ensure data consistency or compliance with business rules. For example, you may want to prevent users from creating Cases through quick create in all apps except Outlook.
Here’s a simple JavaScript approach to achieve this.
The Code
function successCallback(appName, executionContext) {
if (!appName.includes("Outlook")) {
var formContext = executionContext.getFormContext();
alert(appName + " - Avoid creating cases via quick create.");
formContext.ui.close();
}
}
How It Works
-
Check the App Name
The function checks whether the current app includes the keyword “Outlook.” This allows you to target only specific apps. -
Get the Form Context
executionContext.getFormContext()
provides access to the form, allowing you to control the UI elements. -
Notify the User
An alert informs the user that quick create is restricted for the current app. -
Close the Form
Finally,formContext.ui.close()
prevents the user from completing the quick create operation.
Why This Matters
-
Maintain Data Quality: Preventing quick creates in certain apps ensures that cases are entered through proper channels.
-
Custom Business Rules: This allows you to enforce company-specific workflows.
-
User Awareness: Alerting users provides immediate feedback and reduces errors.
Using simple JavaScript functions like this can give Dynamics 365 admins and developers control over user actions without heavy customization. By checking the app context and controlling the UI, you can enforce rules and improve data integrity with minimal effort.