Tag Archives: power automate
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!
Download SSRS report as a PDF with Power Automate – Part 2
In this blog, we will see how to extract the value for PdfDownloadUrl so we can load it into another request and get our PDF.
Download SSRS report as a PDF with Power Automate – Part 1
In this blog, we will see how to retrieve PDF Download URL from the console using the SSRS report. Step 1 – Create a new flow and set the trigger to Manually trigger a flow. Step 2 – After you have your trigger, you need to add two inputs to it, Report Name and Report XML. Step 3 – Then, add a List Rows action from the Dataverse connector and configure it to lookup the report by the Report Name. Step 4 – Setup the report viewer – We do this using the HTTP with Azure AD connector, specifically the Invoke an HTTP request action. Step 5 – We need to authorize our connection to use this action. If you’re using Dynamics 365 online, grab your CRM URL (including https://) and paste it in for both Base Resource URL and Azure AD Resource URL. Method POST Url of the request /CRMReports/rsviewer/reportviewer.aspx Headers Content-Type: application/x-www-form-urlencoded Body of the request id=report&iscustomreport=Custom Report&reportnameonsrs=Name on SRS&CRM_Filter=encodeUriComponent(ReportXML)&reporttypecode=Report Type For encodeUriComponent – Use the following encodeUriComponent(triggerBody()[‘text_1’]) Step 6 – Extract the PdfDownloadUrl from the Report Viewer page. Let’s extract the value for PdfDownloadUrl so we can load it into another request and get our PDF. We’ll do this in 3 parts in Part 2.
Creating Custom Connector for Shopify in Power Automate- Part 2
In Part 1, we created a Custom connector for Shopify and added One Action to retrieve customer data. In this blog we will add more Actions to our Shopify Connector. Actions: Create Customer Update Customer Retrieve all the products Create a new Action to create a new customer and repeat the steps as done in the previous blog(Part 1) 2. Add a request 3. Select the verb and Post request URL, to create a new customer in Shopify URL-: https://{apikey}:{password}@{hostname}/admin/api/2021-10/customers.json Example URL (For reference)- https://9ed959ec1ed8536c82689353bf247c78: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@sans-the-label-designer.myshopify.com/admin/api/2021-10/customers.json 4. In the Request area, choose body then Edit. 5. In the Parameter area, you now see all the parameters that the API expects to create a new customer. We will make the first name, last name, and email as required. Select ‘first_name’ click on more commands(…) and then click on edit. 6. Add a response Go to Response section and click on “Add default Response” NOTE- you can add sample response from the Shopify API Documentation Customer (shopify.dev) 7. Paste the sample in “Body” and click on Import 8. Once all the actions are done, click on Update connector 9. Perform the below actions similarly like the above action- Update Customer: Create a new Action Enter Summary, Description, and Operation ID Summary: Update Customer Description: Update Customer in Shopify Operation Id: UpdateCustomer Go to Request and Click on “Import from sample” Select the verb and PUT the request URL to update customer in Shopify URL- https://{apikey}:{password}@{hostname}/admin/api/2021-10/customers.json Example URL(For reference)- https://9ed959ec1ed8536c82689353bf247c78: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@sans-the-label-designer.myshopify.com/admin/api/2021-10/customers/{customer_id}.json Add a response. Retrieve all Products Create new Action Enter Summary, Description, and Operation ID Summary: Retrieve All Products Description: Retrieve All Products Operation Id: RetrieveAllProducts Go to Request and Click on “Import from a sample” Select the verb and GET request URL to retrieve all the products. URL-https://{apikey}:{password}@{hostname}/admin/api/2021-10/customers.json Example URL (For reference)- https://9ed959ec1ed8536c82689353bf247c78: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@sans-the-label-designer.myshopify.com/admin/api/2021-10/products.json Add a response. 10. Using Custom Shopify connector in MS Flow. Go to Custom and select Shopify connector You can see all the actions Output-
Creating Custom Connector for Shopify in Power Automate- Part 1
In this blog we’ll learn how to create a custom connector for Shopify using Power Automate. Go to Apps and click on “Manage Private Apps” 2. Create on “Create private app” 3. Provide app name and email 4. Give permissions based upon your requirements No Access Read Access Read and write 5. Click on Save and then click on create new private app 6. After creating app, we get API key, password and URL Creating Custom Connector in Power Automate 7. Go to Power Automate->Click on Data->Custom Connectors 8. Click on “+ New custom connector” –> Create from blank. Give a name to your connector and click on “continue 1. General 9. You can upload an image, background color and description as you want or desire 2. Security 10. Select Authentication type as “Basic Authentication” and give label to the parameters. 3. Definition 11. In Definition, you can create Triggers and Actions based on your requirements. Click on “New Action” 12. Enter Summary, Description and Operation ID 13. Go to Request and Click on “Import from sample” 14. Enter the verb and Get request URL to retrieve the single customer detail Verb: GET, URL: https://{apikey}:{password}@{hostname}/admin/api/2020-10/customers/{customer_id}.json Example- https://9ed959ec1ed8536c82689353bf247c78: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@sans-the-label-designer.myshopify.com/admin/api/2021-10/customers/{customer_id}.json Here, {Customer_id} is the input parameter. A request would look like the one below- Add response 15. Go to Shopify API Documentation: Customer (shopify.dev) and copy the JSON file and enter it in Add default response->body 16. Click on Create Custom Connector 4. Test 17. Add a new connection 18. Enter the API key and password 19 Create a new customer in Shopify app and enter the customer ID in GetCustomer 20. Click on “Test operation” to test your connector Hope this helps!!
Creating HTML table using Power Automate
The Create HTML Table action in Power Automate is a useful tool, but lacks any formatting or styling options. In this blog, we’ll see how to create a HTML table in Power Automate. Use Case: When quote is marked as won, close opportunity as won and send Email to the owner of the Opportunity with below details – Email Subject – Opportunity Won! Email Body – Customer Name – Below Table- Solution:Step 1-The requirement is quote should be modified and marked as Won. Trigger on When Quote Modified. Step 2- Initializing the customer with variable actions Step 3- Put a condition that the trigger works only when quote is Won (status code=4), then change opportunity to Won. Step 4- On quote status marked as Won, update the opportunity as Won. Step 5- Listing Accounts associated with Opportunity Step 6- Use Compose: Data Operation and enter the required record URL. Edit the Id by entering the opportunity Id from dynamic content. Similarly for quote URL details as well. Step 7- Using select operation to create a required table in the given format. Using href tag place the outputs of opportunity link and quote link in the key section respectively. Step 8- Create a HTML table and enter the output table of select operation. Step 9- Create 3 new steps using Compose operation to remove the unrequired part of the URL using replace expression. Step 10- Create a new step using compose operation and enter the required CSS style for the table to be sent in the mail and attach the final output in the inputs. Step 11- Send an Email and enter the final output in the Email body. Step 12- Email sent This is how we create HTML table in Power Automate. Hope this helps!!
Understanding Primary Key notations in Dataverse connector in Power Automate
In case it’s your first time creating a Cloud Flow using Dataverse connector and dealing with Primary Key of the Activity Type of entity, here’s a quick tip to keep in mind. Normal Entity As a creator for Flow, let’s say you have listed Records of an entity called as Accounts (out-of-the-box), you’ll notice that the name of the entity Activity Entity Now, if you try to search for the Name of the Activity entity, it won’t appear as it does for other entities, instead just search “Unique” and you’ll find an entry for Unique identifier of the activity entity – Name of my Activity entity is ‘Snapshot’, but it doesn’t show up when I search Snapshot. So instead, just search “Unique” or “Identifier” On the contrary, out-of-the-box entities have their own names named as Primary Keys Hope this is useful!
Store Customer Voice Survey Response to Dataverse Custom Entity using Cloud Flow
In this blog, we will learn how to store the Customer Voice survey response to the custom entity as OOB entities which holds that response data is complex and data is stored in multiple related entities. Step 1: Create a Customer Voice Project and Survey Log in to the Customer Voice Portal and Create a new Project. Select a Blank Template and click on Next. After creating a survey you need to select the Environment location in which Customer Voice Data will get stored. To select the location click on See all environment. Select the Environment location and complete the configuration of the Project. Step 2: Add the Survey Form Fields. Now, we will add the fields that need to be filled by the target audience or based on requirements. After creating your Survey form, you can click on the Preview to view in Desktop and Mobile Mode. To share the form, click on the “Send” tab. There are three options by which you can share the survey form — Scan the QR Code, Embed the Form in Website or App, and share using a short link. I will copy the short link and use it to fill the survey form. You can also create Cloud Flow to automate the survey sending process. Comment down below if you want a blog on the same. Let’s see it in action, I have submitted one response in Survey that we have created. Customer Voice Survey CSD Entity: During the configuration of the Customer Voice Project, we have selected the environment location. In that environment, there are some OOB Entities that have been created to store the Customer Voice Survey Data in CDS / Dataverse. We will Open the CRM Environment and we will Advance Find for the “Customer Voice Survey”. After clicking on the result, you will see the survey that we have created from the Customer Voice portal is also visible in Dynamics 365 CRM as shown below screenshot. Open the Customer Voice survey record. Go to Related and select the “Customer Voice survey responses”. You will see the response that we have submitted after the creation of the Survey Form. Open the Customer Voice survey responses record. To see the responses to each question submitted by the Audience, open the Related “Customer Voice survey question responses”. Open any Customer Voice survey question responses record. You have two fields Question — Lookup to Customer Voice Survey Questions Response — String value of responses submitted by the audience. Link to Documentation:Entity Reference for Dynamics 365 Customer Voice Step 3: Create a Custom Entity and Cloud Flow. I have created a Custom Survey response entity that has the same fields to store the response when any audience submits the response. Step 4: Create Cloud Flow to store the responses to Custom Entity. Create a flow and the trigger will be “When a row is added, modified or deleted” Dataverse connector. Configure the Triggering Connect as shown below screenshot: Now, we will list all the records of responses. To do so we need to use the “List rows” Dataverse connector and configure it as mentioned in the screenshot. We will declare the Variable to store all the question responses. These variables will be used to create the new Custom Survey Response. We will add a switch case that will match the Questions and store the responses to the respective Flow variable. After adding all the switch cases, we will create a record in CDS / Dataverse using the “Add a new row” Dataverse connector. Save the Cloud flow and test it. Cloud Flow in action Hope this helps!!!
Last and First expression in Cloud Flows – Part I
Let see how we can use last and first expression in Cloud Flows. We can use last and first expression get first and last value in array, strings and also we can use first and last expression to get first and last record from list of records in cloud flows Let get started!!!!! Let say you have string named “A Datum Integration” and we want first character of the string, then use below expression. Syntax – first(<string>) I have initialized a string “A Datum Integration”. Add a compose and use first as below. As a result, will get a first character from the string i.e A Output – 2. Similarly, we can use last expression to get last character from the string. In this case character “n” should be output Syntax – last(<string>) Output – Stay tuned for Part II.
Send a notification on Microsoft Teams when a record is created or Updated or Deleted in D365 CRM using Power Automate
In this blog, I am going to explain how to send a notification on Microsoft Teams when a record is created or Updated or Deleted in D365 CRM using Power Automate Steps involved in Power Automate: Select trigger, in my case I used CDS connector when a record is created, updated or deleted. Select trigger condition, in my case I used Update. Select entity name, in my case I used Opportunities. Select Scope, Organization. Add new step to flow. Search Microsoft Teams and select Post a message. Select Team where you want to post a message. Select Channel from team where you want to send a notification. Enter Message in message box. Click Save and check teams. Congratulations! You have successfully created the required flow. Hope this helps!!