Posts

Showing posts from September, 2021

Date and Time Formatting in Power App

Image
Under this blog, we will learn how to show a date and time value in various formats using Power Apps. For this post, we will use Today() function to get the Date and Now() function to get the Date and Time. However, you can replace this with SelectedDate from the DatePicker control, or you can also use  DateValue()  or  DateTimeValue()  function to generate a Date (or DateTime). We have previously looked into how to get first date of a month and last date of a month. First, we add two labels, one for  Today()  and another for  Now() To format the date, we use the Text() function and specify the format that we want. For example, if we use Text(Today(), LongDate) , then it will give as below: In the same manner, the other most commonly used formatting options available are:

Increase number of rows returned from Get Items SharePoint Action under Power Automate

Image
By default, SharePoint Get Items action only returns 100 items which matches your Filter Query.  You must always try to use ODATA filter query to reduce the number of rows that are being returned to you. This will make your cloud Flows much for efficient. If you have a large SharePoint List and your use-case requires, getting more than 100 items, then you will need to make a small setting change to the Get Items action  in your Flow. You will have to do this change each time you add a Get Items action requiring more than 100 items. 1 - If your requirement is upto 5000 records In this scenario, you can change the Top count property to 5000. 2 - If your requirement is upto 100,000 records Under this scenario, click the 3-dots ellipses next to the Get Items action and turn on the pagination settings with Threshold equal to or less than 100,000 depending on your use-case. Note that your license type may restrict the maximum number your can use in the Threshold settings. All license types a

Generate QR code within Power Automate

Image
In this post we will learn how to dynamically generate QR code using Power Automate and then send that as a PDF attachment to an email address. For this post we will use Google Charts API, however note that since this is an external API so you need to check with your organizational data loss prevention policies, data security policies before making any API calls. Additionally, since this is a third-party API, this may be discontinued in the future and hence you may want to plan for this. The URL to generate a QR code looks as below: https://chart.googleapis.com/chart?cht=qr&chs= 300x300 &chl= powerplatformguide.blogspot.com Here we dynamically specify the dimensions of the QR code and its content based on our requirement. To build such a Flow, we will follow the following steps: 1 - Create an Instant Flow with three user input parameters as below: 2 - Add an action using OneDrive connector to upload a file from URL with parameters as seen below. We need to make sure that the de

Restrict Attachment control in PowerApps to accept Excel files only

Image
In one of the previous posts, we learnt how we can create a notification from Power Automate when a certain file-type is uploaded to a SharePoint Document Library. In this post, we will learn how we can restrict Power Apps attachment control to accept only a certain file-type. We will use Excel file (.xlsx) as the accepted file-type, however this can be similarly customized to any file-type(s). In the Attachment control, go the property  OnAddFile  and enter the following code: UpdateContext(     {         validFileType: EndsWith(             Lower(Last( AttachmentControl .Attachments).Name),             "xlsx"         )     } ) Now, the context variable that we have created, i.e.  validFileType  can be used to provide error message to the user, such as disabling the submit button or if using in-built Form, then putting in the errorMessage datacard. Updating error message datacard: Coalesce(     Parent.Error,     If(         !IsBlank(DataCardValue4.Attachments) && !va

Get start and last date of month using Power Apps

Image
In a previous post, we looked at how to get first date and last date of a month using expressions in Power Automate.  In this post, we are going to look at how we can get the same information in Power Apps. Here, we have used Today() to get the dates based on current date, however it can be made even more dynamic by using DatePicker and replacing Today() with DatePicker1.SelectedDate All dates calculated in this post are in the US format: MM-DD-YYYY First Day of Month DateValue(Month(Today()) & "/" & "1" & "/" & Year(Today())) First Day of Next Month In this step, we add 1 month to the first day of the current month DateAdd(     DateValue (Month(Today()) & "/" & "1" & "/" & Year(Today())),     1,     Months ) Last Day of Month In this step, we subtract 1 day from the first day of the next month DateAdd(     DateAdd(         DateValue (Month(Today()) & "/" & "1" &a

Get start date of month and last date of month dynamically from Power Automate

Image
There can be multiple business use cases where you want to know start date and end date of the month in a dynamic manner, either where a date is provided to you, or you are using current date. For example, if you want to filter your data-source to show records for an entire month. This can be achieved using expressions within Power Automate. In this post, we are using current date/time to obtain first and last date of the month. Start date of the month startOfMonth(utcNow(),'yyyy-MM-dd') Last date of the month There is no in-built function to calculate last day of month, so we will first calculate first day of the next month and then subtract 1 day from it. First date of next month : startOfMonth(addToTime(utcNow(),1,'month'),'yyyy-MM-dd') Last date of current month: addDays(startOfMonth(addToTime(utcNow(),1,'month')),-1,'yyyy-MM-dd')

Show A DropDown In PowerApps Containing Only Remaining Months In The Year

Image
Within your Power Apps, you want to have a DropDown control which will show only the remaining months of the year. For example, if you are opening the Power App in September DropDown control will show you months from September to December only. We can achieve this in three steps as below: Create a collection which contains all months as text Create another collection, which appends month-number to each month Add a DropDown control and Filter collection from step 2 to show only months where month-number is greater than or equal to current month number 1 - Create a collection of all months This can be done by adding formula below at App OnStart: Collect(     colMonths,     Calendar.MonthsLong() ); This will give a collection of 12 rows, one for each month: January, February, …, December 2 - Append Month-Number to this collection This can be done by adding formula below just after the step 1 ForAll(     colMonths,     Collect(         colNumberedMonths,         Last(             FirstN(  

Detect When A Particular File-Type Is Uploaded To SharePoint Document Library

Image
You have a SharePoint Document Library where your users are uploading documents. You then use that information to perform other automated tasks such as closing tasks, getting approvals, sending notifications etc.  However you don't want your users to upload a particular file-type, for example, you don't want people to upload Excel Macros into the SharePoint Document Library. Every time someone uploads an Excel Macro file, you want to email them about your policy. To construct this in Power Automate, we will use endsWith() expression. We will create a Condition block and check if       endsWith(triggerOutputs()?['headers/x-ms-file-id'],'.xlsm') is true Under the "Yes" branch of this Flow, we can email the person who has uploaded the Excel Macro file about the policy, or take any other step as per our business use-case.

Get Link To A Particular Flow Run

Image
There can be various situations where you need to know the link to a particular Flow run, for example in case of a failure, or if you want to store the unique ID of each run against your data record for future audits or traceability. In this post, we will learn: How to get ID of the cloud Flow How to get unique ID of a cloud Flow run How to get link to a cloud run The trick to get these details is the workflow() expression, which returns all details about the workflow during run time. To add this into your Flow, simply use the expression:  workflow() A sample output of this expression is in below format: {      "id" :  "/workflows/e54ef274a2f14b54af75fabc3c3c86d3" ,      "name" :  "8a854a53-5863-47d1-acc9-c5993d8f48ff" ,      "type" :  "Microsoft.Logic/workflows" ,      "location" :  "westeurope" ,      "tags" : {          "flowDisplayName" :  " FLOW-NAME " ,          "en

Hello World

Hello World. I have been working with Power Platform for around two years now, with a lot of development work in the last one year. I am starting this blog to give "How-To" solutions and other tutorials mainly related to Microsoft Power Apps and Microsoft Power Automate. At the time of this post, I am Microsoft certified in Power Platform Fundamentals. In the Community Forums on powerusers.microsoft.com , I try to help the community and refresh my skills in the process. My username is @happyume , please feel free to tag me in your questions and I would try my best to help. If you want me to cover a particular topic, then please feel free to leave it in the comments section. Stay Safe!