370 likes | 405 Views
Learn top-notch strategies in using logic to design and customize forms in PowerApps for optimal user experience and functionality.
E N D
Best Practices for using Logic in PowerApps Laura Rogers, Microsoft MVPIW Mentor – SharePoint & PowerApps Training Company BRK2282
Changing Control Properties • PowerApps offers multiple interfaces for editing properties • Formula Bar • Tab Menu • Property Pane &Advanced Pane
Form – The Control for User Input Visually design your form, with Cards for each field
Creating Forms • Display modes: • Edit – used for both new forms and editing existing ones. • Display – view an existing item • Pick a data source, like a SharePoint list • Pick cards (Fields)
DEMO: Creating a Form New customized SharePoint list form,New standalone app with a form
Cards on a Form Label Input or Value Select data source Each data card can include a label and either a value or input field Choose number of columns and layout Select necessary fields and decide on format
About Cards • Check boxes to add cards • Each card = a field • Drag to rearrange • Pick a layout & number of columns • Snap to columns – to auto arrange • Drag to adjust card widths • Advanced properties are “locked” by default
Tree structure of controls. Screens = “Parent” Hierarchy of Controls Screen Form Card Controls in card
PowerApps Formulas • Whatever is typed in this box, is a formula • Formula = one or more functions • Semicolons in between functions • Select a parenthesis, to highlight the corresponding one, as seen here:
Interact with a Form • To start using a form, a function must be used. Click a button to fill out a new form Click to edit an existing item Click to view an existing item
Form Functions and Modes Form Modes Mode= Newbrand new form Mode= Editmodify existing form Mode= Viewread existing form • NewForm() • EditForm() • ViewForm() • SubmitForm() • ResetForm() These tell the form what its mode is
New, Edit and View Modes Example form is called FrmEditCustomer
Default display mode is inherited from the parent form. Unlock a card, to edit DisplayMode. Card Display Modes
Display Modes Examples Edit NewForm & EditForm View (read only) ViewForm Disabled Edit View Disabled
Card Display Mode Example Parent.DisplayMode= Edit Cards inherit parent. DisplayMode = Parent.DisplayMode
Logic on Display Mode • Goal:Customer Status is read only for new forms. • IFMode = NewTHENDisplayMode.ViewOtherwiseDisplayMode.Edit
Logic on Display Mode • Goal:Customer status is disabled if the current user is not a manager • IFCurrent user has no direct reportsTHENDisplayMode.DisabledOtherwiseDisplayMode.Edit
Visibility – show and hide controls • Every control has a Visibility property. • Visibility is always a Boolean. true or false • Goal: The hours used field should only show if project status is complete.
Reference a Field Value • There are several methods • Selected item in a galleryWon’t work on new items • Current item in a formWon’t work dynamically • Field value in a controlMost reliable & dynamic
Validation Conditions • Card property is called Required • Required = Boolean (true or false) • Use an IF statement to set conditional required fields • If estimated cost is greater than $5,000, the manager field is required:
DEMO Logic in forms
Submitting a Form • Forms don’t come with a Submit button • Use anything: • Property: OnSelect • SubmitForm(NameOfFormControl) • Then what? Best Practice: OnSuccess property- set logic that happens after the form is submitted, such as navigating to another screen. • Common practices: • Navigate() • Back() • Set variable • Send email Button Shape Icon
Gallery Basic Info Galleries: display a list of records • Can be horizontal or vertical • Select a layout or use blank layout Contextual: • The first row in the gallery, is the Template. It dictates the behavior of all subsequent rows
Connecting Galleries to Forms • From a gallery or table list of items, create an edit button inside of the gallery item (template). • Edit the form and also navigate to the screen that the form is on. • EditForm(YourFormName);Navigate(ScreenName) • On the form itself: • Form property: Item • If editing or displaying an existing item, which item? • Example: The selected item in a gallery called galExpenseDetail
DEMO Connect a form to a gallery
Please evaluate this sessionYour feedback is important to us! Please evaluate this session through MyEvaluations on the mobile appor website. Download the app:https://aka.ms/ignite.mobileApp Go to the website: https://myignite.techcommunity.microsoft.com/evaluations