JavaScript Archives -

Category Archives: JavaScript

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 :

Custom Field Validation for Website Fields in Dynamics CRM

Posted On December 14, 2022 by Vidit Gholam Posted in Tagged in

Dynamics 365 provides functionality to create a text field of type website field where the user can type in the website name. But out of the box, it has no validation to validate if the user is actually putting a web URL or just a text value, this can be achieved using simple JavaScript.  In this blog, let’s see how to put a validation on a website field in CRM so that users enter the correct data.  I have created a website field in CRM and here is how it looks.  Using the below javascript code you can put a validation on this website field. Code:       validateWebsiteURL: function (formContext, fieldName) {          if (formContext.getAttribute(fieldName)) {              var websiteurl = formContext.getAttribute(fieldName).getValue();              if (websiteurl != “”) {                  var pattern = new RegExp(‘^(https?:\\/\\/)?’ + // protocol                      ‘((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|’ + // domain name                      ‘((\\d{1,3}\\.){3}\\d{1,3}))’ + // OR ip (v4) address                      ‘(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*’ + // port and path                      ‘(\\?[;&a-z\\d%_.~+=-]*)?’ + // query string                      ‘(\\#[-a-z\\d_]*)?$’, ‘i’); // fragment locator                  if (!pattern.test(websiteurl)) {                      formContext.getControl(fieldName).setNotification(‘Website: Enter a valid Website URL.’);                  } else {                      formContext.getControl(fieldName).clearNotification();                  }              }          }      }  I hope this helps 😉! 

Share Story :

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

Share Story :

SEARCH BLOGS:

[gravityform id="36" ajax="true"]

FOLLOW CLOUDFRONTS BLOG :