Category Archives: Power Automate
How to Send D365 CRM Emails with Attachments Using Power Automate
Introduction In this guide, we’ll walk through the process of sending emails from D365 CRM with attachments using Power Automate. This step-by-step approach will help you understand how to automate your email communications from CRM with attachments efficiently. Use-Case Let’s say you’re working on a project where you need to send emails from D365 CRM that include attachments. In this example, the document is stored in SharePoint, and its URL is linked within the CRM record. This setup is common in CRM where files are centrally stored in SharePoint but need to be easily accessible in CRM for email communication and tracking in CRM. However, this approach is versatile—whether you want to attach specific documents, generate them dynamically, or handle a range of file types, it can be adapted to meet your use-case needs. Why this solution? Main objective of using D365 Emails is the ability to track the emails to the record to keep track of communications in timeline. Also, manually attaching documents to each email is time-consuming and prone to errors. With Power Automate, you can automate this process, ensuring that every email includes the right attachment without extra steps. This solution not only saves time but also reduces the risk of sending incorrect or outdated files, keeping your communications accurate and efficient. Implementation – Step by Step As per my use-case, I have added a column in Accounts table that will hold my SharePoint file URL which I’ll use in power automate. Step 1: Trigger the Flow when a flag is marked true to send email report. Step 2: Get the file content using SharePoint path Step 3: Create a new ‘Email Message’ record in data verse (Add a new row) Step 4: Add a new row for ‘Attachments’ and link to email message record Add the custom value as shown below Add Base64 to your file content Add file name Step 5: Send the email That’s it Let’s test it – Results Trigger the flag (as per my use-case) The Email record with attachment Conclusion By integrating Power Automate to handle attachments from SharePoint, you streamline your email process, save time, and minimize errors. This solution is especially valuable for cases requiring frequent attachments or centralized file storage, as it keeps communication efficient and files up-to-date. We hope you found this article useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com
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 :
Remove duplicate values from an array using Power Automate Flow
Hello everyone! In this blog, we will demonstrate how to schedule a flow that sends emails to all the owners of opportunities using Power Automate Flow. Scheduled flows are the best option for actions that need to be automated on a schedule and will run at a specific time or date. For instance, using this approach, you might schedule a daily data upload to Dynamics 365 or SharePoint. Use Case: Power Automate flow sends a reminder notification to the owners of Opportunities. To avoid multiple emails being sent to the same owner, we need to remove duplicate email addresses. Step 1: Log in to the required Power Apps environment using URL make.powerapps.com by providing username and password, click on Create on the left-hand side as shown below, and click on Scheduled cloud Flow. Step 2: Mention the date and time. It will appear as this. Step 3: Initialize a variable ‘Email_addresses’ of type Array which will store all the email addresses. Step 4: Use List Rows to find the desired records from the required table. Select the table name. Also, I added the FetchXML code to fetch the required details of an entity. Step 5: Add an ‘Apply to Each’ loop and insert the previous step’s value. This is done so that the value in every iteration is stored in the Array Variable. Add a step of ‘Set variable’ to store the email addresses in the Array. Step 6: Add a new step ‘Compose’ and declare an empty array. This helps to save time when comparing with larger sets. Step 7: Apply the Union function which removes duplicate values. union(variables(‘Email_addresses’),outputs(‘Empty_Array’)) Step 8: Apply the Join function to extract the email addresses. join(array(outputs(‘Union_function_to_remove_duplicate_mail_Values_in_Array’)),’,’) Hope this helps!
Share Story :
Power Automate Tip: Re-submit/Resend Cloud Flow automatically if there’s Server Response Failure or any condition not met
Hello everyone, You may have encountered a scenario in which Cloud Flow failed unexpectedly or failure from Server or certain conditions were not met during execution due to an asynchronous process. As a result, the Flow must be re-submitted, which is accomplished by selecting the Run History and clicking on Re-submit. In this blog, I’ll show you how to use configuration settings to automatically re-submit Failed flows. I’ll use the Parent-Child Flow concept to accomplish this. I made a simple Parent-Child Flow in which the Parent calls the Child Flow, the Child Flow sends Approval to the User, and the response is passed back to the Parent, indicating that the request was successfully completed.If the user rejects the request, it will be resent only when certain conditions for the execution are met. The steps for implementation and a guide to achieving this are outlined below. Step 1: For having Parent-Child Flows, you need to create a Solution and have 2 Flows (Parent – with any Trigger, Child – should be Manual Trigger) Step 2: Below is the Child Flow (I have used PowerApps V2 Manual Trigger) Tip: PowerApps Trigger can be seen and added later into the solution but if Manual Trigger (Blue Icon) is used then it may not show in existing Flows and cannot be used as Parent-Child is not in any solution A simple Flow, where I have sent an Approval to myself where if I have Approved it would send a response back to Parent Flow but if I reject the Approval then it will execute as Failed without passing a response to Parent Flow. Note: I have used Scope block, so if you have many Action controls and anything fails then it won’t send a response to Parent unless you have configured the flow as such. Here, the Red outlined Block, is the deciding block and the Blue block is the responding Block that will execute only if User Approves the Approval Request. Step 3: Configure the ‘Run-Only’ user for Child Flow on the main page. ‘Run-Only’ defines on who’s behalf to run the flow in the context of, since Child Flows are independent. Step 4: Below is the Parent Flow and the configuration for re-sending Child Flow in case of failure As you see, I have called the Child Flow once and displayed the output of the Child Flow. Because I’m only invoking the Child Flow once, I need to change the configuration for dealing with failed responses so that it can retry the submission of a failed response. On the Child Flow action, click the ellipse (3 dots) and then settings. For the specific action, a settings page will appear. Now we see the ‘Retry Policy,’ which determines whether the flow should retry in the event of a failure with certain conditions. In this case, I used a fixed interval; see the screenshot below. Step 5: That’s all. Now I have tested initially by rejecting the 1st request and the Retry Policy triggers and sends the 2nd request and I approve it. Thus completing the entire flow. Here’s the count of retries that occurred when you see the Run History of Parent Flow with deeper insights Hope this helped 👍🏻
Share Story :
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!
Share Story :
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.
Share Story :
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.
Share Story :
Set multiple not resolved Email Ids as To Party CC Party & Bcc Party in D365 Email Message records using Cloud flows
Many a time it happens that we need to send emails that may be an email notification etc. to clients, with the power automate capabilities we can schedule, trigger, manually run, and do want not to automate these notification emails. But the road blocker to all of these is not resolved email IDs, i.e. email IDs that cannot be resolved as Contacts, Accounts, Users in CRM. We need to make changes to system settings to allow messages to these unresolved Id we have already covered this in the Blog : [https://www.cloudfronts.in/power-automate/send-email-to-not-resolved-email-ids-from-workflow-cloud-flows/] In this blog let’s see how we can set multiple not resolved Email Ids as To Party CC Party & Bcc Party in D365 Email Message records using Cloud flows ToParty, CCParty, BccParty are all Activity Parties and they have a ParticipationTypeMask integer value associated with them more on Activity Parties and Types in this link [https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/activityparty-entity?view=op-9-1] ParticipationTypeMasks are as below : Sender : 1 ToRecipient: 2 CCRecipient: 3 BccRecipient: 4 In Cloud flow create a new email record, click on “Switch to Input entire array”, populate the email in the address used field and ParticipationTypeMasks as shown below : Hope this helps! Thank you
Share Story :
Get Option Set Labels in Power Automate flows
Every Option set Option has two Values associated with it : Label Value – which is a free text field. Value – Which is an integer value as In any Power Automate flow by default, we only get the integer value of an Option Set Option. In this blog let’s see we can get a Label of an Option Set Option. On my Accounts in CRM, I have an Option set Account Type. I have used a Get row by ID Action to get the Account Record whose Account Type Label I need to get. The next step is to check the Raw outputs of this Trigger Action and search for your Option Set field name. You will see 2 values in the body of the Raw outputs as shown below. Expression : outputs(‘Get_Account’)?[‘body/cfs_accounttype@OData.Community.Display.V1.FormattedValue‘] Gives the Label: Business Combination. Expression : outputs(‘Get_Account’)?[‘body/cfs_accounttype’] Gives the Value: 224520002. Inputs: Output : Hope this helps ! Thank you.