Posts

Showing posts with the label Power Apps

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:

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....

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" ...

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(    ...