Sunday, 2 May 2021

Canvas Apps - Auto populate Option Set value in the Canvas App Form


Introduction

Hi Everyone,

Hope you are well and staying safe!

In today's #PowerGuideTip30, I will show you how to auto-populate or set value in Option set field in Canvas App.

I have designed a Canvas App for Event Management purposes, where I have added a screen that the Event Organizer uses to create an Event. This screen has an Option Set field called 'Event Status' that shows the status of the event.

I don't want to allow the Event Organizer to set the Event Status value manually and want to auto-populate its value to 'Submitted' instead.



Solution

To auto-populate value in Option Set value or Set value in Option Set value you should use Choices() expression.
  • The Choices function returns a table of the possible values for a lookup column.
  • Use the Choices function to provide a list of choices for your user to select from. This function is commonly used with the Combo box/ Drop Down control in edit forms.

Syntax

Choices( column-reference )

column-reference – Required. A lookup column of a data source or Option Set Field column. Don't enclose the column name in double-quotes. The reference must be direct to the column of the data source and not pass through a function or control.

Implementation

Choices('Event Status (Events)'.Submitted)

where 'Event Status (Events)' represents the Event Status column of the Event table in Microsoft Dataverse and Submitted is the Option set value that I want to auto-populate.



Note: I want to auto-populate the option set value, hence I have used the Choices(....) expression directly on the items property of Combo box. If you want to set the value on button click then you can use the same expression on onselect property of button control.

Useful Reference





I hope you found this PowerGuideTip helpful. 

Stay tuned for #PowerGuideTip31

Thursday, 8 April 2021

Quick guide to use PCF Controls (Custom Code Components) in PowerApps Portals


Introduction

Hi Everyone,

I hope you are well, staying safe and healthy.

Today I am extremely happy to share the recent Microsoft update, that Custom Code Components (PowerApps Component Framework Controls) or PCF Controls are now supported in PowerApps Portals.

For those who do not know about Custom Code Component or PCF Controls, Please bear with me, because In today's PowerGuideTip29, I am going to share a quick guide to use the custom code components in PowerApps Portals.

What is Custom Code Component or PCF Controls?
  • Custom controls let you transform fields that traditionally contain text into visualizations. Similarly, you can use custom controls to transform datasets, such as a view, to display in a more visual rendering rather than a list of records. 
  • Custom controls can appear as visualizations on forms, dashboards, views, and homepage grids. You can set one type of custom control to appear in the web browser client while having a different custom control appear in your Dynamics 365 for Customer Engagement phone or tablet mobile apps. For example, you could use a number input custom control for a field in web browser clients and a slider custom control for the phone app. 
  • After the customization is published, users can fully interact with the control to change the value, such as by sliding the control when using the linear slider custom control. Changes are automatically saved when the form is closed just as they are when the user changes a traditional field on a form.


How many types of Custom Controls are available in the Model-driven app?
  • You can use a rich set of additional controls to create a more touch-friendly experience on model-driven apps. These include sliders, switches, multimedia players, input masks, calendars, and other controls.
  • You can find the list of all OOB Custom Controls here.

Can I create my own Custom Control (PCF Controls)?

Yes, of course, you can create your own Custom Controls as well based on your business needs. There are few PCF Champs out there, who have designed so many useful and wonderful custom controls. You can download these controls and can start using them.

You can find the PCF Gallery here

Check this article for step by step guide to create your own custom controls.


How to use Custom Control in PowerApps Portals?

You need to perform the following steps in order to use the Custom Control in PowerApps Portals.

Pre-requisites:
  • PowerApps License or Trial Instance
  • System Admin rights
  • Portal version must be  9.3.3.x or higher.
  • Your starter portal package must be 9.2.2103.x or higher.
Step 1 - Build and package your code component. Check here
or
Step 1 - Use the existing custom control

Step 2 - Add the custom control to a field in the Model-driven app





Step 3 - Create Basic Form in Portals
  • For demonstration, I have created a new weblink (My Account) under Profile Navigation Web Link sets and associated it with My Account Web Page. Anf finally I have associated the My Account web page with the My Account Basic form.
  • In My Account Basic Form, I am displaying the portal logged-in user account details. Hence, I have chosen Record Associated to Current Portal User  as RecordSource Type and took form in Edit mode, so that the portal user could update their account details






Step 4 - Create Basic Form Metadata for each Custom Control field in Basic Form

For demonstration, I have used custom controls on the following highlighted fields.


To display the custom control applied on the model-driven app forms field, you need to create a Basic Form metadata for each field and set its Control Style property to 'Code Component' as highlighted below 



Step 5 - Configure Entity Permission for Web Resource table


Associate appropriate Web Role to the Table Permission. I want to display the Custom Controls to all Authenticated Users. Hence I have associated Authenticated Web Roles to the Table Permission.



Step 6 - Clear Portal Cache (or Sync Configuration) and Test Custom Controls on Portals.




Useful Source & References







Hope you found this article helpful.

Stay tuned for the next PowerGuideTip30.
Blogger Widgets