100% found this document useful (1 vote)
1K views

Power Apps Cheatsheet

The document provides common expressions in Power FX to navigate screens, update or insert data without forms, get the first day of the month, and handle lookups and person pickers when working with SharePoint. It includes expressions for navigating to a new screen, updating data with Patch, getting the first day of a month, filtering on a person picker, patching data into fields like a person picker in SharePoint, and setting the default value of a person picker field.

Uploaded by

Junior God
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views

Power Apps Cheatsheet

The document provides common expressions in Power FX to navigate screens, update or insert data without forms, get the first day of the month, and handle lookups and person pickers when working with SharePoint. It includes expressions for navigating to a new screen, updating data with Patch, getting the first day of a month, filtering on a person picker, patching data into fields like a person picker in SharePoint, and setting the default value of a person picker field.

Uploaded by

Junior God
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Power FX Common Expressions To Know First

www.pragmaticworks.com
Problem Expression
Navigate to a Navigation can be done two ways: either go back to the previous screen you cam
new from or navigate to a specific screen.
screen Navigate(ScreenName)
Optionally, you can specify an effect during the
transition: Navigate(ScreenName, ScreenTransition.Fade)

Updating or The Patch function is one way to update or insert data without using a form. For
example, you can tie it to an OnChange even of a drop down box.
inserting data
without a form For inserting a record:
Patch(DataSource, Defaults(DataSource), {ColumnName:"Value1",
ColumnName2:Number2}) Similarly, you can update data when you select an item in
a gallery:
Patch(DataSource, ThisItem, {ColumnName:”Value1″, ColumnName2:Number2})

Get the first Some systems will require you insert the first day of the month vs
Day of today’s date.

the month Date(Year(Today()), Month(Today()), 1)


Would return 3/1/2021 if it were 3/16/2021. Replace Today() with your own date
picker if you want the customer to pick the date instead of always getting today’s date
as shown below.
Date(Year(DatePicker1.SelectedDate), Month(DatePicker1.SelectedDate), 1)
For the last day of the month, you can use the With statement to construct your logic.
The below code finds the first day of the next month then subtracts one day from
that, giving you the last day of the previous month. With the With statement, you
essentially, create a variable that’s only in scope of this one command. In my case
that scope is only in the scope of a text label.
With({DateSelected:Date(Year(DatePicker1.SelectedDate),
Month(DatePicker1.SelectedDate), 1)}, DateAdd(DateAdd(DateSelected, 1, Months),
-1, Days))

www.pragmaticworks.com
Problem Expression
SharePoint Lookups and the Person Picker in Sharepoint require some variations to your code in
Variations Power Apps since it’s a packed field, meaning that the one field has a bunch of items
inside of it with references. This gives you the ability to navigate the hierarchy easier in
with a Power Apps.
aperson
For filtering based on a Person Picker based on the person who’s signed in:
apicker //Put this code in the App OnStart
a Set(varUserEmail, User().Email)
a //Gallery code or wherever you want to filter
a Filter('Assembly Work Orders', Owner.Email=varUserEmail)
a Patching is especially challenging into a Person Picker and a choice column. Both are shown
a below showing you how to unpack the column before inserting into your list. The below is
aa showing inserting with Patch into a SharePoint list with a choice column called Status and a
Person Picker column called Owner. A title column is required also for SharePoint.
a
Patch(‘SharePoint List Name’, Defaults(‘SharePoint List Name’), {Title:”Your record title here”,
a Status:
a {‘@odata.type’:”#Microsoft​.Azure.Connectors.SharePoint.SPListExpandedReference”,
a Value:”Complete”}, Owner:{ ‘@odata.type’:
“#Microsoft​.Azure.Connectors.SharePoint.SPListExpandedUser”, Department: “”, Claims:
a
“i:0#.f|membership|” & User().Email, DisplayName:
aa User().FullName, Email: User().Email, JobTitle: “”, Picture: “” } }) Filtering on a choice column
a requires that you specify the value of the choice as shown below with a drop-down filter.
a Filter('SharePoint List Name', ChoiceColumn.Value=Dropdown1.SelectedText.Value)
a Defaulting a drop-down box in a form to your name in a person picker column
a Set the DefaultSelectedItems property to the following if your form is called Form1 and your
a Person Picker column is called CreatedBy. Note the code is going to check to see if the form is
in New mode and do this or if it’s in edit mode, it will keep its existing value from the list.
a If(Form1.Mode = New,{
a '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
a Claims:Concatenate("i:0#.f|membership|",User().Email),
a DisplayName:User().FullName,
Email:User().Email
a },
a ThisItem.CreatedBy)

www.pragmaticworks.com

You might also like