JavaScript Archives -

Category Archives: JavaScript

Auto Refresh Subgrid in Dynamics 365 CRM Based on Changes in Another Subgrid

In Dynamics 365 CRM implementations, subgrids are used extensively to show related records within the main form. But what if you want Subgrid B to automatically refresh whenever a new record is added to Subgrid A, especially when that record triggers some automation like a Power Automate flow or a plugin that creates or updates related data? In this blog, I’ll walk you through how to make one subgrid refresh when another subgrid is updated — a common real-world scenario that enhances user experience without needing a full form refresh. Let’s say you have two subgrids on your form: Whenever a new record is added in the Chargeable Categories subgrid, a Power Automate flow or backend logic creates corresponding records in Order Line Categories. However, these new records are not immediately visible in the second subgrid unless the user manually refreshes the entire form or clicks on the refresh icon. This can be confusing or frustrating for end-users. Solution Overview To solve this, we’ll use JavaScript to listen for changes in Subgrid A and automatically refresh Subgrid B once something is added. Here’s the high-level approach: Implementation Steps 1. Create the JavaScript Web Resource Create a new JS web resource and add the following code: How It Works To conclude, this simple yet effective approach ensures a smoother user experience by reflecting backend changes instantly without needing to manually refresh the entire form. It’s particularly helpful when automations or plugins create or update related records that must appear in real-time. By combining JavaScript with Dynamics’ form controls, you can add polish and usability to your applications without heavy customization. I hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com.

Share Story :

Disqualify Single or Multiple Quotes in Dynamics 365 with One Click!

If you’ve ever needed to mark multiple quotes as lost in Dynamics 365, you know the default “Close Quote” dialog can be slow and repetitive.In my recent project, the sales team wanted a faster way, one click from the main Quotes view, to disqualify single or multiple quotes, without opening each one or clicking through extra prompts. Using the out-of-the-box CloseQuote action, a small JavaScript function, and a custom Ribbon Workbench button, I built exactly that. Here’s how. Why I Needed This Our sales team often manages multiple quotes at once. The standard process meant: It was time-consuming, especially for bulk operations. We needed a quick, grid-based action that would: Step 1 – Using the OOB CloseQuote Action Dynamics 365 provides a built-in CloseQuote bound action that changes the state and status of a quote to closed. Instead of creating a custom action, I decided to call this OOB action directly from JavaScript. Step 2 – JavaScript to Call the OOB Action Here’s the function I wrote to handle both single and multiple quotes: Step 3 – Adding the Ribbon Button in Ribbon Workbench Now, the button will be available directly on the Quotes view. Step 4 – Testing the Feature This reduced what was previously a multi-click, per-record task into a single action for any number of quotes. Why This Works Well To conclude, by combining the OOB Close Quote action with Ribbon Workbench, I could instantly disqualify quotes from the main grid, saving hours over the course of a month. If you’re looking to simplify repetitive processes in Dynamics 365, start by exploring what’s already available out of the box, then add just enough customization to make it your own. 🔗 Need help implementing a custom button or enhancing your Dynamics 365 sales process? At CloudFronts, we help businesses design and implement scalable, user-friendly solutions that streamline daily operations and improve adoption. Whether it’s customizing Ribbon Workbench, integrating OOB actions, or building tailored automation, our team can make it happen. 📩 Reach out to us at transform@cloudfronts.com and let’s discuss how we can optimize your Dynamics 365 environment.

Share Story :

Power Pages + Power Automate: Retrieve SharePoint Files via HTTP Trigger Flow

When building a Power Pages site to fetch SharePoint files, I initially relied on the official Power Pages flow trigger—“When Power Pages calls a flow.” However, the flow didn’t trigger reliably when initiated from the site. Despite proper configurations, the trigger wouldn’t execute consistently, leading to broken file fetch operations. To overcome this, I replaced the unreliable trigger with a Power Automate flow using an HTTP request trigger. This method allowed me to invoke the flow through a JavaScript function executed on page load, passing the required record ID dynamically. The HTTP approach not only worked reliably but also gave me more control over the request and response. This blog post outlines that workaround, from setting up the HTTP-triggered flow to integrating it seamlessly with Power Pages. Background and the Problem Power Pages provides a native trigger to call Power Automate flows. While ideal in theory, this approach often fails in practice due to: After spending time investigating these issues without consistent results, I decided to switch to a more controlled and universally reliable method using a HTTP trigger. My Workaround – HTTP Trigger Flow Power Automate Flow Setup: Trigger:Start with the “When an HTTP request is received” trigger. Define the request schema to accept a recordId— in this case, an orderId. Compose (Request Variables):Add a Compose action to extract the incoming ID. List Rows – Document Locations:Use Dataverse → List rows to retrieve the SharePoint Document Location related to the Order (based on the passed orderId). This assumes your files are stored in folders linked to Dataverse records. Condition – Check If Folder Exists:Use a Condition to check if any document location was found: If record exists → proceed, If no records found → terminate the flow (folder doesn’t exist). Compose – Relative URL: Compose – Folder Path:Combine the folder path: Get Files (SharePoint):Use the SharePoint Get files (properties only) action with the dynamic path set to the DocumentPath variable. Return Response:Format the SharePoint file metadata (Name, Link, Type) and send it back using the Response action. JavaScript (Executed on Page Load) Why This Works: Pros: Cons: To conclude, if you’ve faced reliability issues with native Power Pages flow triggers, the HTTP request method can be a game-changer. It enabled me to deliver a seamless experience for retrieving SharePoint files, and it can do the same for your project. In future iterations, I plan to enhance this by adding bearer token authentication and caching metadata for even faster performance. Want to integrate Power Automate flows reliably with Power Pages? Reach out to CloudFronts—we help businesses implement scalable, reliable Power Platform solutions every day. You can contact us directly at transform@cloudfronts.com.

Share Story :

Comparing Asynchronous Patterns in C# and JavaScript

Asynchronous programming is essential for building responsive applications, especially when dealing with time-consuming operations like API calls, file I/O, or database queries. Both C# and JavaScript provide powerful tools to handle asynchronous code: Promises in JavaScript and Tasks in C#. However, managing these manually can lead to complex, nested code. Enter async/await—a syntactic sugar that makes asynchronous code look and behave like synchronous code, improving readability and maintainability. Async/Await in JavaScript JavaScript relies heavily on Promises for asynchronous operations. While Promises are powerful, chaining them can lead to callback hell. Async/await simplifies this by allowing us to write asynchronous code in a linear fashion. Scenario: Fetching User Data from an API Instead of chaining .then() calls, we can use async/await to make API calls cleaner. Without Async/Await (Promise Chaining) With Async/Await (Cleaner Approach) Benefits:✅ Easier to read – No nested .then() chains.✅ Better error handling – Structured try/catch blocks. Scenario: Sequential vs. Parallel Execution Sometimes we need to run tasks one after another, while other times we want them to run in parallel for efficiency. Sequential Execution (One After Another) Output: Parallel Execution (Faster Completion) Output: Async/Await in C# C# uses Tasks for asynchronous operations. Before async/await, developers relied on callbacks or .ContinueWith(), leading to complex code. Scenario: Downloading Files Asynchronously Instead of blocking the UI thread, we can use async/await to keep the app responsive. Without Async/Await (Blocking UI) With Async/Await (Non-Blocking UI) Benefits:✅ UI remains responsive – No freezing during downloads.✅ Clean error handling – try/catch works naturally. Scenario: Running Multiple Database Queries If we need to fetch data from multiple sources, async/await makes it easy to manage. Sequential Database Queries Parallel Database Queries (Faster Performance) Key Takeaways ✔ Use async/await to avoid callback hell in JavaScript and blocking calls in C#.✔ Sequential execution (await one by one) vs. parallel execution (Promise.all / Task.WhenAll).✔ Error handling is simpler with try/catch instead of .catch() or .ContinueWith().✔ Improves performance by keeping UIs responsive while waiting for I/O operations. By adopting async/await, you can write cleaner, more maintainable asynchronous code in both JavaScript and C#. 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

Share Story :

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.

Share Story :

Triggering Custom Action Without Modifying the Record in Dynamics 365 using JavaScript

In Dynamics 365, custom actions allow you to perform specific business logic, such as sending emails, making calculations, or calling external services. Often, these actions are triggered based on field updates or changes to records. However, there may be situations where you want to trigger a custom action through a button click, without modifying any record fields or triggering unnecessary updates. In this blog, we’ll explore how to use a button to trigger a custom action for a creating a specific task record in Dynamics 365 using JavaScript, that too, without modifying the record. Here’s the JS code used to trigger the action: Attach the JavaScript function to the button ‘Create Task’ event of the Case form, so that every time a case is created, the follow-up task is automatically generated. Click on the ‘Create Task’ button. And here, we have the follow up task created. Happy Developing! 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.

Share Story :

Easy JavaScript Examples for Dynamics 365 CRM – Repository

Are you tired of spending hours searching for the right JavaScript functions to use in Dynamics 365 CRM? If so, you’re not alone. Developers often struggle to find commonly used functions scattered across different sources, making it frustrating to build quick solutions or bug fixing. What if you had a single repository containing all the essential JavaScript functions at your fingertips? That’s exactly what this blog offers, a one-stop resource where you’ll find everything you need, from retrieving field values to automating actions on forms. With these functions in one place, you can save time, eliminate guesswork, and focus on creating impactful solutions for your Dynamics 365 projects. As a Microsoft Certified Trainer (MCT) and Microsoft Certified Professional, I’ve spent my career deploying Dynamics 365 solutions for organizations across the globe. My hands-on experience in architecting and implementing complex solutions has given me deep insight into the challenges developers face—one of the most common being finding and applying the right JavaScript functions efficiently. Let’s explore the most commonly used JavaScript functions for quick reference and seamless development Best Practices: Always check if a field or control is null before interacting with it. Keep JavaScript functions modular and reusable. Avoid using deprecated APIs, always follow the latest Microsoft documentation. Conclusion: JavaScript is a game-changer when it comes to customizing Dynamics 365 CRM, and having a go-to repository for commonly used functions can save you significant time and effort. With these functions at your fingertips, you’ll be better equipped to build dynamic forms, automate processes, and enhance the overall user experience. And smoother operations for your business. Now that you’ve explored these essential JavaScript functions, why not take your Dynamics 365 knowledge even further? Check out this blog on error handling in Dynamics 365 plugins to strengthen your expertise in server-side customizations as well. Bookmark this repo, and let’s make development faster and easier together!

Share Story :

Trigger Power Automate Flow using JavaScript – Bi-Directional

Hi All,  This blog will be a continuation of my previous blog –  Trigger Power Automate Flow using JavaScript – Uni Directional Now, feedback is essential when sending a request to determine whether it was successfully performed or failed somewhere.  You can accomplish this by forwarding a response back from where the flow was invoked.  I’ll use the same situation as in my previous blog, where I send a notification by greeting a person’s name if exists, or else I will greet a friend.  Check out my previous blog to learn how to build your Flow and JavaScript.  Steps to pass the response back within Flow​  Step 1: Add a response that will be sent back from where the Flow was invoked.  Quick Tip: I am checking if ‘Name’ is present in my dynamic content. If yes, then greet the person else greet a Friend  Formula: if(contains(triggerBody()?[‘DynamicData’], ‘Name’), triggerBody()?[‘DynamicData’][‘Name’], ‘Friend’)  Steps to add into the JavaScript Step 1: Initially we created JS to trigger the flow, now we will add the code snippet to accept the response from Flow. Add the following Code: Step 2: Trigger the JS and watch the output I get as Alert (I have used the console page to trigger my JS for example purposes) Hope this helps in achieving a response from the Power Automate Flow!

Share Story :

Trigger Power Automate Flow using JavaScript – Uni-Directional

Hi All, Did you know you can use JavaScript to trigger Power Automate flows and pass input data? So, I’ll show you how to do that, as well as how to pass strict structured data and dynamic schema in Power Automate. In the next blog, I’ll talk about Trigger Power Automate Flow using JavaScript – Bi-Directional Steps to follow for Initial Setup Step 1: Let’s create a Power Automate Flow and define the input JSON schema.Go to: Power Automate Create an Instant Flow with the trigger ‘When a HTTP request is received‘ Step 2: Let’s outline the input schema and then focus on the output in a ‘Compose’ block. I’ll describe two types of inputs. (Strict and Dynamic).Our strict schema will be identified by a specific pattern indicating how the input should be given.Our dynamic schema will be recognised by an unknown pattern, and input will not always be fixed. Click on ‘Use sample payload to generate schema’. Apply the following code, click on Done and you will see the schema in ‘Request Body JSON Schema’. Add a Compose Block to check the output of the request and save the Flow. URL will be generated and is ready to be used. Let’s now proceed to create JavaScript to trigger this flow Steps to follow for calling Flow using JavaScript Since I’ll show the code snippet, adjust it as per your use case. Note: Copy your HTTP Post URL from the trigger as it will be used in the JavaScript Step 1: Type the following code Step 2: Execute the JS with ‘TriggerFlow.Main()‘. Note: Make sure you pass Execution Context to the JS Step 3: Check your Power Automate Flow History and open the Run. That’s how Power Automate is triggered using JavaScript. Hope this has helped you 🙂 Next blog – Trigger Power Automate Flow using JavaScript – Bi-Directional

Share Story :

How to Use Solution Checker to identify usage of the OrganisationData.svc endpoint (Odata Deprecation for Web resources)

The Organization Data Service is an OData v2.0 endpoint introduced with Dynamics CRM 2011. The Organization Data Service was deprecated with Dynamics 365 Customer Engagement v8.0 in favor of the Web API, an OData v4.0 service. For more details please follow the link https://powerapps.microsoft.com/en-gb/blog/odata-v2-0-service-removal-date-announcement/ OData v2.0 Service removal date announcement | Microsoft Power Apps To determine the deprecation in your old javascripts below is the blog you can refer to. Step 1: Log in to the required Power Apps environment using the URL make.powerapps.com by providing a username and password and select your environment accordingly. Step 2: Go onto Solutions and click on [+ New solution] from the menu bar Step 3: Name your Solution and fill in all the details which include the Publisher as well as the Version details. Step 4: Go inside your solution and select Add existing option. Click on More and select Web resource. Step 5: Search for your web resources using your custom publisher. For example, your publisher might be new_ or abc_ and so on.It depends on how you name your publisher. Step 6: Select all the web resources you required and once done, go back to the solution and click on the ellipses(3 dots) of your solution. Click on the option Solution checker and select Run. Step 7: We can also view the Run Status of the solution. Step 8: Click on Ellipses(3 dots) again of the solution you have worked on and click on Solution checker and then you can view the option Download results. Click on that option and once you download it, it will be downloaded in the form of xlsv(excel). Try searching the issue for web-avoid-crm2011-service-data on that excel sheet. Hope this helps!!!

Share Story :

SEARCH BLOGS:

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange