Professional Documents
Culture Documents
Some Important Formula For App Development in PowerApp
Some Important Formula For App Development in PowerApp
C# Corner
New EBook Download: Angular 7 for Beginner
4 0 10.6k
Introduction
In this article, I am going to explain some important and useful formula to develop an app in PowerApp.
Formulas
To fetch the user’s manager properties, first, we need to connect to the Office365Users to PowerApp.
Syntaxes
Mail - Office365Users.Manager(User().Email).Mail
(Where the User().Email is current login user’s email. You can use any other user’s email to get the one’s respected Manager)
Department - Office365Users.MyProfile().Department
Let’s say as an example, I want to show a setting button to only admins, not to the remaining users.
To achieve this, create a SharePoint list for admins, then set a condition on the visibility of a button to check if the user is
available in the list to show the button.
Syntax
Set the current user and user’s manager by default on screen load
InonVisible
Focus of the screen,
C# Corner
New EBook Download: Angular 7 for Beginner
For Manager,
UpdateContext({managerProfile - Office365Users.Manager(Office365Users.MyProfile().Id)})
onSelect
Property - OnSelect,
Syntax
Explanation
• Patch is a method to update a SharePoint list item, will be trigger onSelect or onChange of button
• ‘MyList’ is a list name
• ID is the SharePoint item’s Id where you want to update
• ‘Title’ is the columns internal name, which you want to update
• "My new title" is user input
Enable/Disable Button
Syntax
If(IsBlank('MyList Box'.Selected.Value),DisplayMode.View,DisplayMode.Edit)
Explanation
• If Selection is Blank (No Selection), the button will be in disable mode (DisplayMode.View)
• If you select something from dropdown/list box, the button will become enabled (DisplayMode.Edit)
• Where the 'MyList Box' is the selection box
Whenever you are navigated from one screen to another screen based on selection of an item, the below syntax will be used to
display the selected item’s property.
Syntax
InsomeGallery.Selected.DisplayName
Focus (These are just to get some idea to implement in your applications)
C# Corner
New EBook Download: Angular 7 for Beginner
Screen Navigation
Case - When you wish to navigate to a particular named screen from the current screen by clicking a button/Icon, put the below
syntax on button’s onSelect property.
Property - onSelect,
Syntax
Navigate(SomeScreenName, ScreenTransition.None)
Explanation
• Where the ‘Navigate’ is an inbuilt function which will use to navigate the screen.
• ‘SomeScreenName’ is the destination screen where you wished to navigate.
• ‘ScreenTransition.None’ is one of the screens to navigate the motion style out of ‘Cover’ and ‘Fade’.
Case - When you want to post input form’s data to a SharePoint list on a particular button click.
Syntax
SubmitForm(AddedEditForm);NewForm(AddedEditForm)
Explanation
• Where the ‘SubmitForm’ and ‘NewForm’ are in-built functions which are useful to post data and reset to an empty form
after submitting the data respectively.
• ‘AddedEditForm’ is a name of the input edit form, which is the user-defined name.
Case - When you want to delete a selected item from a list box by clicking on a button.
Syntax
Remove(MyList, First(Filter(MyList,EmpName=ListBox.Selected.EmpName)))
Explanation
• Where the ‘Remove’ is an inbuilt function which is useful to delete a selected item from the SharePoint list
• ‘MyList’ is a name of the SharePoint list.
• ‘EmpName’ is one of the column’s names and ‘ListBox.Selected.EmpName’ is one of the properties of the selected item
from List Box which contains the list of items.
• Where ‘First(Filter(MyList, EmpName=ListBox.Selected.EmpName))’ is filtering the matched records from MyList to the
selected item from the List Box. So that it helps to remove the particular item from the list
Syntax
Remove(MyList, First(Filter(MyList,ID=Gallery.Selected.ID)))
Explanation
• This is just similar to the above case, except, where we are removing the item by passing a particular ID.
Syntax
Explanation
Syntax
Explanation
Syntax
Distinct(Filter(MyList,EmployeeName.DisplayName =User().DisplayName),EmployeeName.DisplayName)
Explanation
Case - When you want to display Current Date and Time on a label/text field
Syntax
Now()
(Ex: DataCardAdminUserValue.Selected.DisplayName & "-" &Now())
Text(Now(), "[$-en-US]yyyy")
RGBA(0,0,0,0)
)
Explanation
Case - When you want to perform updating on bulk records by clicking a button
Syntax
ForAll(CheckedItems,Patch(ChecklistItemsSource,LookUp(ChecklistItemsSource, Id = CheckedItems[@Id]),{Status:"Done"}))
Explanation
Case - When you want to perform update on a particular record by clicking a button
Syntax
Explanation
This is just similar to the above case, except, where we are updating the item with user input ‘Submitted’ to Status column by
passing a particular ID.
Case - When you want to get a particular item’s property from the collection using an index.
Syntax
Last(FirstN(MyCollection, IndexValue)).ColumnName
(Ex: Last(FirstN(SomeCollection, 1)).ID
Last(FirstN(MyCollectionForEmployeeInfo, 3)).Employee.DisplayName
)
Explanation
Case - When you want to create a collection/Array with filtered items on a button click
Button’s Property:OnSelect/onChange,
Syntax
InClearCollect(UserDefinedCollectionName,Filter(‘ListName’,EmpName=Gallery.Selected.EmpName))
Focus
C# Corner
New EBook Download: Angular 7 for Beginner
Explanation
• ‘ClearCollect’ is an in built method which will clear an array first then push items
• ‘CollectionForselectedQuarter’ is user defined collection Name
• Where the filtered items are pushing into the respected collection on a button click
Condition in MS flow
Syntax
@greater(length(body('Filter_array_1')), 0)
@equals(length(body('Filter_array_2')), 0)
Expand/Collapse
Case - When you want to hide and show two icons, set variable and use as following:
• Icon1
onselect
UpdateContext({ExpandColapse: !ExpandColapse})
visible
ExpandColapse
• icon2
onselect
UpdateContext({ExpandColapse: !ExpandColapse})
visible
Not(ExpandColapse)
• Item
Not(ExpandColapse&&thisItem.selected )
Property - Text,
Syntax
IsBlank(LookUp(MyList,EmployeeName=CurrentUserName&&Year=RunningYear,Employee.DisplayName))
Explanation
Where it will filter and return the Employee Name from the SharePoint list where it has EmployeeName=CurrentUserName and
Year=RunningYear, and the CurrentUserName and Running are the variables which are defined on the screen’s OnVisible under
Advanced.
In Focus
C# Corner
New EBook Download: Angular 7 for Beginner
OnSelect/onChange
Explanation
‘ForUnique’ is a user-defined variable name setting with a string and current datetime
Case - When you want to reset form while using submission with patch methods
Property1: OnSelect,
Syntax
Conclusion
This article will help us to develop any kind of customized applications with the help of the above formula. I hope we can
achieve almost any kind of issues or required things with the help of those formulas. This will be helpful to those who want to
start with PowerApp. Expect many more things related to Microsoft Flows in my coming articles.
Thank you.
Conditions Filter Post Data With Code Powerapps Powerapps Formulas SharePoint Update/Patch A Particular Record
Mahipal Reddy
I’m a developer and designer living in Hyderabad, Telangana, India. I spend my days with my hands in many different areas of
web development from front end programming (HTML, CSS,bootstrap,Office UI Fabric, Angular and j... Read more
595 294.5k
4 0
Type your comment here and press Enter Key (Minimum 10 characters)
In Focus
C# Corner
New EBook Download: Angular 7 for Beginner
TRENDING UP