Tag Archives: Dynamics 365
Mastering Event Handlers in Dynamics 365 Finance & Operations (X++)
Event handlers in Dynamics 365 Finance and Operations (D365 F&O) allow developers to extend standard functionality without overlying customization. They help in: In this blog, we’ll explore: Types of Form Event Handlers in D365 F&O Triggered by UI interactions (form opens, button clicks, etc.) Event Type When It Fires Common Use Cases OnActivated When form loads Initial validation, default field values OnClosing Closed form Run custom logic on action OnInitialized Create new record Real-time validation OnPostRun Process completion Adding new process in flow To create event handler Step 1: Solution Explorer -> Add new class Give it proper name, so any other developer can recognized it ( Example : CustTableForm_EventHandler ) Use case: Automatically update particular field when user open particular customer details. Step 2: Get event code snippet. AOT-> Forms -> View Designer -> Events -> Copy event handler Paste all code to newly created classs. Additionally, there are separate events for methods also you can use that events to perform certain operation before that method or after that method get called. You can add your custom logic inside your event handler code snippet. In below example if current record has customer no. is equal to specific no. then it will validate particular field and update the form. Pro Tips To conclude, event handlers are powerful tools for customizing D365 F&O while maintaining upgradeability. By: You can build robust solutions that align with business needs. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
Transforming Development: How Copilot is Revolutionizing Developer Productivity
Software development has been around since the 1940s.We started with punch cards, then machine language, followed by assembly, high-level programming languages, low code, no code, and now AI-assisted coding. Along the way, several tools have been developed to make programmers’ jobs easier, from card sorters and verifiers to debuggers and IDEs. Now, with the advent of AI, we have large language models (LLMs) writing code for us, but I don’t think it’s quite there yet. In this article we’ll see how AI assists developers, what it can do for us today, its limitations, and where it’s headed. The concept of AI began in the 1950s when researchers tried to imbue machines with the magic to think. Early systems followed set rules, but as computers improved and data became more available, smarter methods emerged, such as machine learning, natural language processing, and neural networks. Large Language Models (LLMs) grew from these advances, using huge amounts of data and computing power to understand and create language. This marked a shift from fixed rules to models that learn on their own. By 2025, AI has taken root in most fields, even in places we might not have expected.For example, robotic bees — tiny drones designed to mimic bee behavior, are now being used to assist with pollination in areas where natural bee populations are struggling. These drones combine machine learning and computer vision for navigation, flight control, pollination strategies, and swarm intelligence. Usage Copilot is integrated with both Visual Studio Code and Visual Studio, and it comes with a few LLMs built in by default.Currently, these include Claude Sonnet 3.5, GPT-4o, o3-mini, and Gemini Flash 2.0.If you want to add more models, you’ll need a subscription for Copilot Pro. We can use Copilot Chat to prompt these models directly in the sidebar chat, whether to generate a specific functionality or create an entirely new file. Here, I asked it to create a simple sales order.Notably, it kept the key details — Customer, Item, and Quantity — as parameters without requiring any input. From here, we can click a button to apply the changes to the open file. At the bottom, we can see which file Copilot is currently using as a reference.If we want to stop Copilot from referencing that file, we can click the eye button. We can also ask it to make changes to the generated code. Now, I noticed that while it has parameterized the “Customer No.” for the sales order, it hasn’t actually used it anywhere in the code. If I point this out to Copilot… Instead of using Copilot Chat, we can also get recommendations directly within the file.Here, I’m trying to write a function to delete a sales order based on the given SO No. I can just tab my way into writing the method. One common way I’ve used copilot is to add Guard clauses to methods that I’ve written. For instance – Here, it is referring to Customer and Item record variables, which don’t exist yet. But if I go to the variables section then it knows what I’m trying to do and suggests the same. Now, if I were to make it handle something complex, that’s when the cracks start to show. For example, pulling data from an API and creating customers would require several steps — authenticating with the API, fetching the data, parsing it, handling errors or logging, and finally creating the customers. We get the following as an output – Here, we can see that while it has a surface-level understanding of the code structure and the steps needed to achieve the goal, it struggles with the details. This could be because, unlike open-source languages like Java, Python, or C++, there isn’t as much publicly available source code for AL. I believe Microsoft Documentation would have helped to some degree, but instead, it tends to guess what the correct methods or fields should be. To its credit, the generated code isn’t far off from being functional, especially considering the simplicity of the input prompt. The structure it provides is still a solid starting point and much better than writing everything from scratch. Another example of these “hallucinations” is when it suggests methods that don’t actually exist, like this- However, once you show it what the correct method is, it suggests that – To go one step further, I asked the different models to create an entire project based on the below prompt – Findings: o3-mini 1. The objects it generated had the fewest errors.2. It was the simplest and closest to compiling successfully.3. It returned all the text in a single response, so I had to manually create files from it. GPT-4o 1. Created a Readme.md with project requirement details.2. Automatically generated the necessary project files.3. Farthest from compiling successfully, with most requirements missed.4. There were plenty of hallucinations, including methods that don’t exist in AL at all – like this example below. Gemini Flash 2.0 1. Created a Readme.md with project requirement details.2. Automatically generated the necessary project files.3. Added launch.json, settings.json, and app.json.4. Didn’t meet all requirements but managed to lay some groundwork.5. Struggled with code structure in several places, though still significantly better than GPT-4o.6. Had at least a couple of pages with zero errors. Claude Sonnet 3.5 1. Created a Readme.md with project requirement details.2. Automatically generated the necessary project files.3. Added launch.json and app.json.4. Included a test codeunit, though it had errors.5. Created a permission set for the objects generated.6. All files had one or more errors. In my opinion, Claude and o3-mini are the most useful for coding assistance. HumanEval is a test developed by OpenAI to assess how well language models can write code.It includes 164 programming problems where the model must generate accurate and functional Python code. The HumanEval leaderboard aligns with my assessment as well. Pricing While all these models offer a free trial with a limited set of tokens, they can become quite expensive if you don’t monitor your usage. Below … Continue reading Transforming Development: How Copilot is Revolutionizing Developer Productivity
How to Use the Debugger in Dynamics 365 Finance and Operations
Debugging is an essential skill for developers working with Dynamics 365 Finance and Operations (D365 F&O). The built-in debugger helps you identify and fix issues in your X++ code efficiently. In this blog post, we’ll walk through how to use the debugger effectively in D365 F&O. Prerequisites Before you can start debugging, you’ll need: Access to a D365 F&O development environment Appropriate permissions (developer role) Visual Studio installed (for some debugging scenarios) Enabling Debugging Set up debugging permissions: Navigate to System administration > Setup > License configuration Ensure the “Debugger” privilege is enabled for your user role Configure debugging options: Go to Tools > Options > Development > Debugging Configure your preferred debugging settings Starting a Debug Session There are several ways to start debugging in D365 F&O: 1. Attaching to a Process Open the Debugger workspace Click on Attach debugger Select the process you want to debug (user session) Click Attach 2. Debugging from Visual Studio Open your X++ project in Visual Studio Set breakpoints in your code Press F5 to start debugging (or use the Debug menu) 3. Using Conditional Breakpoints Navigate to the form or process you want to debug After adding the breakpoint, right-click it in the breakpoints list Select “Edit breakpoint” In the “Condition” field, enter your X++ expression Example: custAccount == “US-001” Key Debugging Features Breakpoints Breakpoints pause execution at specific lines of code. You can: Set conditional breakpoints that only trigger when certain conditions are met Set hit count breakpoints that trigger after a specified number of hits Enable/disable breakpoints as needed Stepping Through Code When execution is paused, you can: Step Over (F10): Execute the current line and move to the next Step Into (F11): Dive into method calls Step Out (Shift+F11): Complete the current method and return to the caller Examining Variables The debugger allows you to: View local variables in the Locals window Add watches for specific variables Quickly evaluate expressions in the Immediate window Call Stack The call stack shows: The hierarchy of method calls that led to the current execution point , Allows navigation to different levels of the call stack Debugging Different Scenarios Batch Jobs To debug batch jobs: Set breakpoints in the batch job code , submit the batch job and Attach the debugger to the batch process Business Events To debug business events: Set breakpoints in the event handler code Trigger the business event The debugger will pause when the event is processed Tips for Effective Debugging Use the debugger’s data tips (hover over variables to see their values) Common Debugging Challenges Solution: Use thread debugging and pay attention to execution order Solution: Replicate the production environment configuration as closely as possible Solution: Use targeted debugging rather than broad breakpoints To Conclude, The D365 F&O debugger is a powerful tool that can save you hours of troubleshooting time. By mastering breakpoints, variable inspection, and call stack navigation, you can quickly identify and resolve issues in your X++ code. Remember to use debugging judiciously in production environments and always follow your organization’s guidelines for debugging in live systems. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
Restoring a Deleted Posted Bank Reconciliation in Business Central: A Comprehensive Guide
Are you having trouble restoring a deleted posted bank reconciliation in Microsoft Dynamics 365 Business Central? In this blog, I’m going to guide you through the process of effectively restoring a deleted posted bank reconciliation and ensuring the accuracy of your financial records. You’ll learn the step-by-step procedure to re-post a deleted bank reconciliation, along with best practices to prevent future errors and maintain the integrity of your financial data. Let’s get started! Steps to Achieve Goal: page 50100 BankLedgerEntryEditable { ApplicationArea = All; Caption = ‘Bank Ledger Entry Editable’; PageType = List; SourceTable = “Bank Account Ledger Entry”; UsageCategory = Lists; Permissions = tabledata “Bank Account Ledger Entry” = RIMD; layout { area(Content) { repeater(General) { field(“Document No.”; Rec.”Document No.”) { ToolTip = ‘Specifies the document number on the bank account entry.’; } field(“Statement No.”; Rec.”Statement No.”) { ToolTip = ‘Specifies the bank account statement that the ledger entry has been applied to, if the Statement Status is Bank Account Ledger Applied.’; } field(“Statement Line No.”; Rec.”Statement Line No.”) { ToolTip = ‘Specifies the number of the statement line that has been applied to by this ledger entry line.’; } field(“Statement Status”; Rec.”Statement Status”) { ToolTip = ‘Specifies the statement status of the bank account ledger entry.’; } field(Amount; Rec.Amount) { ToolTip = ‘Specifies the amount of the entry denominated in the applicable foreign currency.’; } field(“Amount (LCY)”; Rec.”Amount (LCY)”) { ToolTip = ‘Specifies the amount of the entry in LCY.’; } field(“Posting Date”; Rec.”Posting Date”) { ToolTip = ‘Specifies the posting date for the entry.’; } } } } } pageextension 50101 PostedBankAccRecon extends “Bank Account Statement List” { trigger OnDeleteRecord(): Boolean begin Error(‘You cannot delete a bank account reconciliation entry.’); end; } To conclude, by following these steps, you can successfully undo a deleted posted bank reconciliation in Business Central. The process involves editing the Bank Ledger Entry, recreating the bank reconciliation with the same details, and ensuring the previously deleted reconciliation is removed through AL. With this approach, you maintain accurate financial records and ensure that your bank account reconciliation process runs smoothly without any discrepancies. If you need further assistance or have specific questions about your Business Central setup, feel free to reach out for personalized guidance. Happy Reconciliation! We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
Seamless Integration: How to Sync Business Central with External Systems Instantly or in Batches
In today’s fast-paced business world, integrating your ERP system (like Business Central) with other external systems is crucial for streamlining processes and ensuring data consistency. However, if you’re new to API integrations or struggling with how to send data from Business Central to another system, don’t worry! In this post, I am going to walk you through the process of sending data from Business Central to an external system using APIs. By the end of this guide, you’ll have a clear understanding of how to perform integrations smoothly, without the complexity. Steps to Achieve Goal: You can easily send data from Business Central to an external system by calling the link set in General Ledger Setup. Below is the logic for sending data via an API. You can encapsulate this logic inside a Codeunit, and call it as needed based on your synchronization requirements: Real-Time Data Sync: If you want the data to be synced in real-time (for example, as soon as new data is entered into Business Central), you can call the procedure within the OnAfterInsert() trigger. This ensures that every time a new record is created, it automatically triggers the procedure to send the data. trigger OnAfterInsert() begin SendPostRequest(Rec); end; Batch Data Sync: If you prefer to sync the data at the end of a batch process (for example, at the end of the day), you can loop through the records using FindSet() and then call the procedure inside the loop. This will send data in bulk at a scheduled time rather than in real-time. procedure SyncDataInBatch() var Rec_SO: Record “Sales Header”; begin Rec_SO.setrange(CreatedAt,today()); // Apply any filter as per your need. if Rec_SO.FindSet() then repeat SendPostRequest(Rec_SO); until Rec_SO.Next() = 0; end; // Below is the logic for posting data from BC to Third Party Applications via API procedure SendPostRequest(var Rec_SO: Record “Sales Header”) var HttpClient: HttpClient; HttpContent: HttpContent; HttpResponseMessage: HttpResponseMessage; HttpRequestMessage: HttpRequestMessage; JsonObject: JsonObject; JsonText: Text; Rec_GLE: Record “General Ledger Setup”; contentHeaders: HttpHeaders; OutPutString: Text; begin Rec_GLE.Get(); Rec_GLE.TestField(“API Link”); // where the other system API link has been stored and we are using via AL HttpRequestMessage.SetRequestUri(Rec_GLE.”API Link”); HttpRequestMessage.Method := ‘POST’; JsonObject.Add(‘system_id’, Rec_SO.SystemId); // Passing Sales Header System ID(GUID) JsonObject.Add(‘document_number’, Rec_SO.”No.”); // Passing Sales Header No JsonObject.Add(‘type’, ‘ReleasedSalesInvoice’); // Passing Sales Header type JsonObject.WriteTo(JsonText); HttpContent.WriteFrom(JsonText); HttpContent.GetHeaders(contentHeaders); contentHeaders.Add(‘charset’, ‘UTF-8’); contentHeaders.Remove(‘Content-Type’); contentHeaders.Add(‘Content-Type’, ‘application/json; charset=utf-8’); HttpRequestMessage.Content(HttpContent); if HttpClient.Send(HttpRequestMessage, HttpResponseMessage) then if HttpResponseMessage.IsSuccessStatusCode then begin HttpResponseMessage.Content.ReadAs(OutPutString); Message(‘%1’, OutPutString); end else Error(‘Error %1’, HttpResponseMessage.ReasonPhrase); end; Conclusion: To conclude, sending data between Business Central and other systems is not as complicated as it might seem. By following the steps outlined above, you’ll be able to create smooth, efficient integrations that will save time, reduce errors, and improve your business processes. Happy Coding! We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
Business Central Translations: Working with XLIFF Files – Part 2
By the end of this guide, you will be able to generate, edit, and implement XLIFF files in Microsoft Dynamics 365 Business Central to support multiple languages seamlessly. This will enable your application to display translated content for UI labels, reports, and messages, ensuring a smooth experience for users across different regions. Why does this matter? Using XLIFF files, businesses can easily localize Business Central applications without modifying source code, making multilingual support efficient and scalable. By leveraging tools like NAB AL Tools, translations can be managed effortlessly, enhancing global usability. Generating an XLIFF File To illustrate the XLIFF process, let’s go through an example where we add a custom field named “Custom_Field” on the Customer Card page. Step 1: Creating a Custom Field First, we create a new field, Custom_Field, on the Customer Card page using AL code: Step 2: Enabling Translation File Feature In the app.json file, ensure that the TranslationFile feature is enabled: Step 3: Building the Project Now, build the extension using the shortcut CTRL + Shift + B. This will generate an .xlf file automatically in the translation folder. By default, the file is generated in English (en-US). Using NAB Extension for Translation To simplify translation tasks, you can install the NAB AL Tools extension from the Visual Studio Code marketplace. This extension helps in managing translation files efficiently by allowing automated translation suggestions and quick file updates. Steps to Use NAB AL Tools: A) Install NAB AL Tools. B) Press CTRL + Shift + P and select NAB: Create translation XLF for new language. C) Enter the language code (e.g., fr-FR for French – France). D) Choose Yes when prompted to match translations from BaseApp. E) A new fr-FR.xlf file will be generated. Translating the XLIFF File To translate the XLIFF file into another language (e.g., French), follow these steps: Example: Translating Report Labels In Business Central RDLC reports, hardcoded text values can also be translated using labels. Instead of writing static text, define labels within the AL code: Using FieldCaption ensures that report labels dynamically adapt to the selected language, improving localization without manual modifications. When switching languages, the label automatically retrieves the corresponding translation from the XLIFF file. Modifying Standard Fields Standard field names in Business Central can also be modified using the BaseApplication.g.xlf file. You can find this file in public repositories, such as: BaseApplication.g.xlf Modifying this file allows changes to default field captions and system messages in multiple languages. Insert value in different languages via AL In Microsoft Dynamics 365 Business Central, AL enables efficient multilingual data handling. The image above illustrates a Customer Card where the “Nom” (Name) field contains the value “testing.” The AL code extends the Customer table, adding a custom field and an onInsert trigger to validate the Name field with “testing.” This ensures data consistency across different language settings. By leveraging AL, developers can automate multilingual field values, enhancing Business Central’s global usability. To conclude, managing translations in Business Central using XLIFF files enables businesses to support multiple languages efficiently. By generating XLIFF files, modifying them for translation, and leveraging tools like NAB AL Tools, businesses can ensure accurate and seamless localization. For further refinements, modifying report labels and system fields enhances multilingual support, improving the user experience across global deployments. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
Business Central Translations: Language Setup and Customization – Part 1
In today’s globalised world, firms frequently operate in numerous areas and languages. To efficiently manage worldwide operations, software with multilingual capabilities is required. Microsoft Dynamics 365 Business Central (BC) includes a powerful translation system that enables enterprises to customise language choices, thereby increasing user experience and operational efficiencies. This article looks at how translations function in Business Central and how they may be used to support global business operations. Why Are Translations Important in Business Central? Businesses that expand into new areas face a variety of languages, currencies, and regulatory regimes. Ensuring that employees can interact with Business Central in their native language improves the software’s usability and productivity. Business Central allows users to configure numerous languages across various modules, allowing workers to work smoothly in their favourite language. It also allows translations for custom fields, reports, and data entry, assuring consistency and correctness in both internal and external interactions. How Translation Works in Business Central Business Central supports several languages, including English, French, German, and Spanish. Here’s an outline on how to activate and use translations successfully. 1. Configuring Language Settings The first step in enabling multilingual support is to configure the Language Settings in Business Central. Users can choose their favourite language or use the organization’s default language settings. This guarantees that when a user logs in, the interface, menus, and forms appear in their preferred language. To configure a language in Business Central: 2. Standard Text Translations Business Central provides built-in translations for standard interface elements and commonly used terms such as “Sales Orders,” “Invoices,” and “Purchase Orders.” These translations are included in the base application by Microsoft. For example, changing the language from English to French automatically updates the captions. However, some standard texts may not be translated by default. To install additional language support: Once installed, the system updates with the new language settings, ensuring a localized user experience. 3. Translating Custom Fields Many businesses customize Business Central by adding custom fields, tables, and industry-specific terminology. While these enhancements improve operational efficiency, they may not be automatically translated in the base system. To resolve this, Business Central provides the CaptionML property, which allows developers to define multilingual captions for custom elements. Example: English: Displays field names and labels in English. French: The same fields are shown with French translations. By implementing the CaptionML property, businesses ensure a seamless multilingual experience even for customized elements. To conclude, Microsoft Dynamics 365 Business Central makes it simple for multinational companies to handle multilingual customers. Companies can improve usability and efficiency across regions by changing language settings, adding extra translations, and ensuring that custom fields are translated using CaptionML. Embracing Business Central’s translation skills enables firms to operate efficiently in a global market while providing a consistent and localized experience to all users. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
A Comprehensive Guide to Backups and Restores in Dynamics 365 Business Central
Managing your organization’s data effectively is a critical task for ensuring business continuity. Dynamics 365 Business Central simplifies this process by offering built-in backup and restore features via the Business Central Admin Center. In this blog, we’ll explore how you can utilize these features to safeguard your environment and handle potential mishaps. Overview of Backups in Dynamics 365 Business Central Business Central automatically manages backups for your production and sandbox environments. These backups are stored securely for a limited period, allowing administrators to restore environments when needed. The retention period and capabilities for restoring backups are influenced by the environment type (production or sandbox). Key Features of the Backup System Restoring an Environment Restoring an environment is a straightforward process, ensuring minimal downtime. Follow these steps to restore an environment using the Admin Center: Step 1: Access the Admin Center Log in to the Business Central Admin Center using your administrator account. Step 2: Select the Environment Navigate to the Environments page and select the environment you wish to restore. Step 3: Initiate the Restore Process Click on the Restore button and choose a backup point from the available restore options. Step 4: Configure Restore Options Step 5: Confirm the Action Review the details and confirm the restore. The system will notify you once the process is complete. To encapsulate, the backup and restore functionalities in Dynamics 365 Business Central offer a reliable safety net for your organization’s data. By leveraging the Admin Center, administrators can easily safeguard business continuity and minimize risks associated with data loss or corruption. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
Get Started with Reservation Hierarchies in Dynamics 365 Finance & Operations
Managing inventory in a systematic way is essential for any business. Dynamics 365 Finance & Operations (D365F&O) provides reservation hierarchies to streamline how inventory is reserved and tracked across dimensions like site, warehouse, batch, or serial number. This guide explains the steps to enable reservation hierarchies and demonstrates their usage with practical examples. Reservation hierarchies are tools that determine the order in which inventory dimensions are used to allocate stock. For example, you might first reserve items by site and warehouse, followed by batch and serial numbers. This process helps ensure that inventory is allocated in a logical and efficient manner. Creating Reservation Hierarchies 2. Define the Hierarchy: 3. Select Dimensions: 4. Save and Finalize: Assigning Reservation Hierarchies to Products After creating the hierarchy, assign it to products to activate its functionality: Repeat these steps for all applicable products to standardize the process. Assigning Reservation Hierarchies to Products After creating the hierarchy, assign it to products to activate its functionality: Repeat these steps for all applicable products to standardize the process. Using Reservation Hierarchies in Transactions Sales Orders: When processing a sales order, the system automatically reserves inventory based on the hierarchy. It allocates stock step-by-step through the defined dimensions. Production Orders: For production, reservation hierarchies ensure materials are reserved systematically, avoiding stock conflicts. Transfer Orders: While transferring stock, the hierarchy helps select inventory from the correct dimensions, improving accuracy. Benefits of Reservation Hierarchies To conclude, reservation hierarchies are a simple yet powerful feature in D365F&O. They allow businesses to control how inventory is reserved, ensuring accuracy and efficiency in every transaction. By configuring them properly, you can streamline your operations and reduce errors. Take the time to test these features in a sandbox environment before using them in your live setup. This will help you understand how they work and ensure they fit your business needs. With reservation hierarchies in place, managing inventory becomes easier and more reliable, helping your business stay organized and efficient. That’s it for this blog! Hope this helps! Keep Sharing!! We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
How to Display the ‘+New’ Quote Button Only for System Administrators Using JavaScript and Ribbon Workbench in Dynamics 365 CRM
Uploading and managing quotes efficiently is crucial for Dynamics 365 CRM users. However, sometimes you may want to restrict certain buttons, such as the ‘+New’ Quote button, to only users with specific roles, like the “System Administrator.” In this guide, I’ll walk you through how to achieve this by leveraging JavaScript and the Ribbon Workbench tool in Dynamics 365. This method allows administrators to control button visibility based on user roles, ensuring that only users with the correct permissions can access sensitive functionality. The Use-Case: Restricting Access to the ‘+New’ Quote Button for Non-Administrators. Imagine a scenario where your organization needs to ensure that only users with a “System Administrator” role can create new quotes in Dynamics 365. This is crucial for maintaining control over who can initiate important processes within your CRM system. Using JavaScript and Ribbon Workbench, you can easily customize the UI to hide the ‘+New’ Quote button for non-administrators. Here’s how this use case can be implemented: In this scenario, your team wants to ensure that only system administrators have access to the “+New” button for creating quotes in the system. For non-administrators, the button will be hidden from both the homepage subgrid and the main quote tab to prevent unauthorized users from creating quotes. By using the Ribbon Workbench tool, a custom JavaScript function is created to check if a user has the “System Administrator” role. If they do, the “+New” button remains visible, and they can create a new quote. For all other users, the button is hidden. Key Components of the Solution 1. Ribbon Workbench: The Ribbon Workbench tool allows you to customize the Dynamics 365 ribbon, enabling you to create custom buttons and define their visibility and actions. It is used to create the new custom “+New” Quote button, which replaces the default button while maintaining system integrity. 2. JavaScript Customization: Custom JavaScript is used to manage role-based access for the “+New” Quote button. The script checks the user’s role within Dynamics 365 to ensure that only users with the “System Administrator” role can view and use the button. This helps enforce security and restricts unauthorized users from creating new quotes. 3. Enable Rule for Button Visibility: An Enable Rule is set to control the visibility of the custom “+New” Quote button based on the user’s role. It ensures that only users with the “System Administrator” role can see and use the button, while hiding it for other users. 4. Custom Button Action (Command): The command linked to the custom “+New” button triggers a custom action (JavaScript function) to open the quote form. This ensures that the action associated with the button aligns with the business needs and provides a seamless user experience for administrators. Step-by-Step Process Sign in to Dynamics 365 using your URL, such as abc.dynamics.com, and enter your credentials or login to make.powerapps.com Create a solution and add the web resource. Once it’s done login to ribbon workbench from XRM toolbox and connect to your organization. After logging in, it is recommended to create a new solution for Ribbon Workbench in Dynamics 365. Ensure that no forms, views, charts, or other entities are included, as Ribbon Workbench may fail to upload the solution with excessive data. Only include the Quote entity with no additional dependencies. Ensure the existing +New Quote button is hidden, as modifying Microsoft-standard buttons is not recommended. Instead, create a new custom button and implement the functionality for creating a new quote Form using custom JavaScript. I have provided the code for this functionality as well. Ensure that the existing +New button for quote would be hidden from the homepage Subgrid and the quotes main tab. Next step would be to create a enable rule. Enable rule is used to control the visibility and availability of a button or command of the button. Name the id of your choice but make sure to add the suffix Enable Rule. Here, un-customised is set to False. By setting isCore (or Un customized) to false, you’re indicating that the button or element is a custom component, not part of the out-of-the-box (core) solution provided by Microsoft. This helps differentiate custom actions from the default ones in the system. Below is the code for the new quote form create and user role-based code. Make sure to select the Function name properly. After setting the enable rule, go to the Commands section in Ribbon Workbench and rename the command. A command defines the action triggered by a button click. Since this is a new button, you’ll need to add the custom form opening code. Below is the function for creating the form. Final Steps: Once the command is added, don’t forget to add the Enable rule that you have created above. Once the command is added, make sure to add all the rules we wrote into the custom button. The image also needs to be added so that the icon can be visible. My custom +New icon looks like this. Testing: Once everything is done, make sure Publish the changes. You can now try to log in from the user that has no System administrator role. Once logged in, you can see that button is not visible. Button will be only visible to user that have system Administrator role. User having no System Administrator role. You can see below that there’s no +New button displayed. To conclude, by following this guide, you can efficiently control the visibility of the ‘+New’ Quote button in Dynamics 365 CRM, making it accessible only to users with the “System Administrator” role. This ensures better control over who can create quotes in the system while maintaining the flexibility of user roles. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
