javascript Archives -

Tag Archives: javascript

How an Australia-Based Commercial Laundry Company Built a Custom Dynamics 365 Sales Dashboard Beyond Standard Reporting

Summary The sales team at commercial laundry and linen rental organization could open any record in Dynamics 365 and still could not answer how much of the open book sat in healthcare. Sector was never a field on a deal, it was four boolean flags on the product, three joins away from the quote a manager wanted to group. We replaced the standard sales dashboards with Custom Sales Dashboard that reads the Dataverse Web API directly, rolls sector up through the line items, and puts leads, opportunities, quotes and signed contracts under a single set of filters. Every tile, cell and chart segment opens the records behind it and exports to Excel with real numbers and real dates. Table of Contents Summary→ Business Challenges→ Solution Overview→ Technical Approach→ Impact→ Conclusion→ Get in touch→ Business Challenges Commercial laundry and linen rental organization runs multiple laundries, called plants in the CRM, and quotes work by the weight a customer sends each week. A deal is a weekly tonnage and a weekly dollar figure before it is anything else, which is why the standard sales charts had so little to say about it. The reporting asks were ordinary. The data model underneath them was not, and every ask broke on a different part of it. Sector is not stored on the lead, opportunity, quote or order. It is independent flags on the product record: healthcare, motel, garments, etc. A chart grouped on the quote has no column to group by A single product can carry more than one flag, so one quote can legitimately belong to two sectors. Grouping without a rule double counts the same dollars Total Amount reads 0.00 on every quote and every order in the org. All money sits in annualrevenue and weeklyrevenue, which the standard sales charts and rollups do not read Contracts are salesorder records. The out of the box contract table is empty, so anything pointed at it returns nothing at all The plant lookup laundry is populated on roughly six quotes in ten. The rest only know their laundry through the originating opportunity Orders copied from an accepted quote frequently carry no line items of their own, so a product level report built on order lines quietly loses them Managers wanted one choice of sector, sales person or plant to move leads, opportunities, quotes and contracts together. Standard dashboards filter each chart against its own entity Nobody could see the forward book: which signed contracts start in the next twenty weeks, and what weekly tonnage each start week brings ⚠The real blocker Every one of these needs a value computed from grandchild rows, from the quote down to its lines down to the product flags. The chart designer groups on fields that exist on the record being charted, and this one does not exist anywhere. Solution Overview We built one page that lives inside the CRM as a web resource. It opens like any other dashboard, signs the user in with the session they already have, and reads live records rather than a nightly copy. The page carries six tabs. Overview holds a pipeline matrix and the stage, sector, sales person and plant mix. Pipeline Activity plots leads and quotes created per week for the last fifteen weeks. Contracts Won shows the forward book by contract start week. Win and Loss compares closed won against closed lost by value and by count. Approvals and Activities measures how long contract, logistics and freight rate decisions take. Reports lists contracted and quoted stock at product line level. Three filters at the top, sector, sales person and plant, drive every chart, tile and table on every tab at once A fourth filter, customer, appears only on the Reports tab because it only narrows those two tables Clicking any chart segment, matrix cell or tile opens a drawer listing the records behind that exact number Each row in the drawer links to the real CRM form, and the whole selection exports to Excel with numbers as numbers and dates as dates ⓘWhy the drill through mattered more than the charts A sales manager who cannot see the eleven contracts behind a bar will not act on the bar. Registering the source records for every visual was the difference between a picture and a working tool. Technical Approach Where the page runs The dashboard is a single HTML web resource, customDashboard, shipped in the main solution. Running inside the model driven app means it inherits the user’s authentication and their record level security, so a sales person sees their own scope without us writing a line of security code. It resolves the org URL from parent.Xrm.Utility.getGlobalContext() and falls back to window.location.origin when it is opened outside a form, which is what makes local debugging possible. SourceDataverse Web API v9.2Live reads with the signed in user’s context Load14 parallel queriesOne Promise.all on page open IndexLookup maps and sector indexProduct flags resolved once, then cached RenderMatrix, tiles and Chart.jsRedrawn in memory on every filter change ActDrawer and XLSX exportRecords behind the number, typed for Excel Everything loads once. Accounts, factories, depots, leads, opportunities, quotes, orders, the three line item tables, products, freight rates, delivery point risk assessments and activities all come down in a single Promise.all, and every later interaction is a filter over arrays already in memory. Changing a filter costs nothing on the network. Rolling sector up from the product The rollup walks the line items of a quote, order or opportunity, reads the flags off each product, and weights each sector by line weight times quantity. The heaviest sector becomes the primary, which is what the breakdown charts group on so the totals stay additive. The full list is kept separately and is what the sector filter tests against, so a quote that touches healthcare and motel appears under both filters and is counted once in the donut. cf_customDashboard.html, sector rollupjavascript function rollupSectors(lines, productIdField) { const weight = {}; lines.forEach(l => { const sectors = PRODUCT_SECTORS[String(l[productIdField] || ”).toLowerCase()] … Continue reading How an Australia-Based Commercial Laundry Company Built a Custom Dynamics 365 Sales Dashboard Beyond Standard Reporting →

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.

Transform Document Management in Dynamics 365: Automate, Organize, and Scale Across All Entities with Custom Pages for Streamlined Document Handling

Introduction Document management is a critical aspect of any organization using Dynamics 365 CRM, and finding a simple, scalable solution can often be a challenge.  In this blog, I’ll show you how PowerApps Custom Pages can transform your document handling experience. By leveraging model-driven capabilities, I’ve built a solution from scratch that allows you to handle multiple document templates at once without the complexity and clutter of traditional methods. Using Custom Pages, you can generate and organize documents across different entities directly within the Dynamics 365 environment, making it easy to scale your solution for any table or scenario. Let’s take a closer look at how Custom Pages can streamline and simplify document management for your organization. The Use-Case: Document Management Application Key Components of the Solution which I have chosen for this use-case and blog Step-by-Step Process Step 1: Create the Custom Page (refer to my previous blog if needed) Create a solution, create custom Page and then embed it into Model-Driven App. I’ve made a sample example below: Step 2: How to retrieve parameters when App is opened. For the App’s ‘OnStart’ property, enter the following code Step 3: Trigger Document Generation App (I have used a ribbon button to trigger using JS) You will need to write a JavaScript in order to trigger and display the Custom Page. Where to find the app name, you will find in the solution. My example is below Step 3: Trigger Document Generation Page Once the document is created, you can close the Page using X button. As per JS code, our code will navigate to Document Tab. Ensure the name of Document Tab is correct. Step 4: Automation to SharePoint Use PowerApps Connector and add your input parameters to it. In the Custom Page, do insert the newly created Power Automate flow and pass the input values respectively Also, once the flow is completed, you can send a response back to Custom Page using same connector but of different action ‘Respond to PowerApp or Flow’. Conclusion Conclusion This Custom Page use-case demonstrates how a thoughtfully designed solution can enhance productivity and user experience in Dynamics 365. By streamlining document creation and navigation, it reduces friction in day-to-day operations, empowering teams to focus on higher-value tasks. Whether you’re a technical developer or a functional consultant, this approach provides actionable insights for building powerful and efficient solutions. References 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. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

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!

Dynamically filter required Fields/Columns from a Record’s BPF and Form and apply Requirement to those fields

Hi Everyone, Let me explain this topic with an example of a scenario that you might encounter. I’ll walk you through how to complete this scenario in a concise manner below. Use Case Let’s say you have a Table (Entity) with or without multiple Business Process Flows (BPFs) that include some required Fields and even on the Form. Even if the required fields are empty and you want to change a field or flag within the form and save the record. We must disable all required Fields on the Form and then re-enable the requirements for those fields. We can do this with some simple JavaScript code. Step 1: Find a trigger point for your JS function to be called.It can be done with a Ribbon Button or by manually changing a Field. Find the code you’ll need below. I’ll be using Ribbon Button to trigger my JS Function. Quick Tip: You cannot get any Attribute Value of a Field residing in BPF directly. You need to get the entire Control of the Field and then call its attribute values. Step 2: Register your JS function onto your Ribbon Workbench or OnChange of any Field on Form. Since I called my function using Ribbon Button, I used “OpportunityForm.executeMain” with Parameters; “CRM Parameter -> Primary Control“ If you’re calling the JS using Field OnChange, then register the function as “OpportunityForm.executeMain” and do pass ‘executionContext‘. In this case, your part of the script will change as below (use this if you use JS on your Form only) OUTPUT This is how all fields will have no requirement on the Form. I took this output before re-enabling the requirement level for the fields. That’s all, I hope this helped you

Make form read-only using JavaScript 

Posted On September 23, 2022 by Richie Jacob Posted in Tagged in ,

One way to lock down a form is through JavaScript. Let’s go through how to do this by looking at the code. var formCustomizations = { disableForm: function (executionContext) { let formContext = executionContext.getFormContext(); let formControls = formContext.ui.controls; formControls.forEach(element => { if (element.getName() != “” && element.getName() != null) { element.setDisabled(true); } }); } } Here when the JavaScript Function Is called and the execution parameter is passed, the user can see the desired output. formContext.ui.controls; Provides the properties and methods to retrieve information about the user interface (UI) controls for several sub-components of the form. formControls.forEach(element => { if (element.getName() != “” && element.getName() != null) { element.setDisabled(true);} Here the forEach loop will traverse and see if there are any fields that are not blank and the field value is not null, then set all that fields to read only on that form. Hope this helps!

Cancel the running flows with JavaScript code

We will look at how we can use JavaScript to cancel flows that are running without canceling each flow manually. To do this, follow the steps below. Let’s look at a scenario where we are seeing the flows that are in a running state and are not terminating. Click on All runs, this navigates you to all flow runs view. When we are in the All runs view, we need to open the developer console in the browser. The developer console can be opened by clicking F12 (or holding fn and F12) on Windows. Or by right-clicking on the screen and clicking Inspect. In the developer console, navigate to the Console pane. To clear the console window, click CTRL + L. The console pane is where we will add the JavaScript code that will cancel the running flows. As can be seen in the next step. // Copy this first and run it in the console var jq = document.createElement(‘script’); jq.src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js”; document.getElementsByTagName(‘head’)[0].appendChild(jq); // … give time for script to load, then type (or see below for non wait option) jQuery.noConflict() //Paste the same again var jq = document.createElement(‘script’); jq.src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js”; document.getElementsByTagName(‘head’)[0].appendChild(jq); // … give time for script to load, then type (or see below for non wait option) jQuery.noConflict() // Then copy this in the console to start the cancelation of the flows. confirm = function () {return true;}; setInterval(function () { $(“.fl-StatusInCell:contains(‘Running’)”).parent().parent().find(‘.ms-DetailsRow-cell’).last().click(); $(‘button[name=”Cancel”]’).click(); },5000); Click the running code after the code is implemented in the console, and the output will be seen below Hope this Helps!

Switching of Forms using Option Set field in Javascript

Use Case – To Switch form based on the value selected from option set field. Steps – 1. We have a Option Set field – “Lead Type“ Based on the Option selected – the form will switch For example – “PMO Member” – On change of the option, it will switch to PMO Member Form “HR” – On change of the option, it will switch to HR Form 2. To get the current form Guid use the following in the console- 3. Below JavaScript Code- Hope this helps!!

How to Dynamically Filter Multi-Select Option set/Picklist in D365 CRM using JavaScript

Posted On April 27, 2022 by Sancia Dcunha Posted in Tagged in ,

In this blog, I am going to show how we can filter a field (multi-select option set) item dynamically based on another field (single-select option set) item. Let’s consider a use case, We have a field named ‘Application Area’ which is a (single-select option set) field and ‘Application Type’ which is a (multi-select option set) field. Let’s have a look at JavaScript where the magic is making this possible. Step 1: Below is the entire code of JS For Table/Entity Main Form customization, select ‘Form Properties’ to include JavaScript function as below, On Load: oApplicationAreaType.Main On Change of field ‘Application Area’: oApplicationAreaType.getDetails Note: Pass the execution context for calling the JS function. That’s all, we have created a dynamic filtering of multi-select option set using JavaScript. Hope this helps!!

To show validation on a field using Regex Expression

In this blog, I am going to show how we can display a validation on the field if the entered text is not in the required format Let’s consider a use case, We have a field name ‘DMV Initial License’ which is a single line of text field. When text is entered the Date format for this field should be MM/YYYY Let’s have a look at JavaScript where the magic is making this possible. Step 1: Regex Expression for Date in the required format MM/YYYY – date_regex = /^(0[1-9]|1[0-2])\/[/]?([0-9]{4})$/ Step 2: Below is the entire code of JS For Table/Entity Main Form customization, select ‘Form Properties’ to include JavaScript function as below, On Change of field ‘ DMV Initial License ’: oCustomerFormCustomization.checkDateFormat Note: Pass the execution context for calling the JS function. Hope this helps!!

SEARCH :

FOLLOW CLOUDFRONTS BLOG :

FOLLOW CLOUDFRONTS BLOG :


Categories

Secured By miniOrange