Applying filter on Multi Choices / Multi-Select OptionSet – Power Apps / Dataverse


Say for e.g. we have 2 multi-select choice columns in our leads table, one is local (My Local Multi Choice Field) and the other field ((My Local Global Multi Choice Field) refers to the global option set field

In our Canvas App, to filter on ‘My Local Multi Choice Field’ by value Local Choice 2 and Local Choice 3, we can apply the below formula.

Similarly, for the Global option set to apply a filter on the Global Choice 2 value, we can compare the field in the lead with the values in the Global Option set.

As we are using “in” operator, we’d get the delegation warning. And for it to work in the case of combo box we would have to set “Allow Searching” to “Off

Hope it helps..

Advertisements

Fixed – Invalid data from the network error in the custom page – Power Apps / Dataverse


Recently in one of our custom pages, we were getting the below error

“Invalid data from the network”

We had this setting “Formula-level error management” as On, switching it off was hiding this error on the page.

To fix it we tried removing the fields one by one to figure out the issue. Eventually, we saw the error was going away if we remove one of the option set fields from the gallery or comment it’s formula. Later when we removed and added the field back in the gallery and the error got fixed for us.

The page loading properly without the error –

Hope it helps..

 

Advertisements

Using Sort, Distinct, Filter together for combo box Items– Canvas Apps (Dataverse)


Just sharing a simple example of applying a formula to the Combo box Items property, which includes Sort, Distinct, and Filter (If).

Below is our Combo Box bound to a lookup field of type Customer. If Contact is the option selected in the radio control, we want to show Contact’s Full Name sorted else Account’s Account Name field.

If( radioBtnCustomer.Selected.Value = "Contact",
    Sort(Distinct(Filter(Contacts,Status = 'Status (Contacts)'.Active),'Full Name'),
        Value,
        SortOrder.Ascending
    ),
    Sort(Distinct(Filter(Accounts,Status = 'Status (Accounts)'.Active),'Account Name'),
        Value,
        SortOrder.Ascending
    )
)

The result –

Also to clear the selection in the combo box when the user changes the option from contact to account and vice versa we can use the Reset function.

Check the below links to learn more about working with Customer lookup –

https://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/working-with-references#show-the-columns-of-a-customer

Hope it helps..

Advertisements

Combo box showing blank values in case of multiple conditions – Canvas App (Dataverse)


Recently while trying to filter combo box Items we were getting the values but it was coming as blank instead of showing the name field.

Below is a sample Form – connected to Leads and Source Campaign is the combo box field (lookup to Campaign)

As we can see without applying the filter we can see the name (Display fields) populated.

Now let us try to filter it based on the Campaign Type field.

Here we have applied a single filter condition.

We can see the combo box getting filtered correctly.

Now we are introducing a variable just to filter it based on condition.

Till now filtering works as expected.

Now let us introduce else condition here.

We can see the combo box getting filtered but not showing the name field of the Campaign set as a display field. Through developer tools also, we don’t see the name returned in this case. The same is the case if we use multiple If or Switch in the formula.

The solution is to filter on Campaigns data source directly, instead of the corresponding Choice field in the Lead.

The result –

Hope it helps..

Advertisements

Fixed – Global variables are not allowed in StartScreen (PowerApps / Custom Page)


Recently while working on a custom page we had a requirement to show different screens on the app start based on a choice field in the record. (The custom page was being opened from a button/command on the form)

For the custom page’s App OnStart we were first removing the curly brackets from the recordID parameter passed to set the ContractId variable followed by setting ContractRecord variable using that GUID in the LookUp function.

Below is the JavaScript used to pass the parameters to the custom page (from the command/ribbon button)

Now based on Contract Type optionset field in the Contract record we wanted to show a different screen as the start screen. However, trying to use the Global Variable in the StartScreen function gave us the error – “Global Variables are not allowed in StartScreen”

The solution here was to use the Param recordId to get the record and set the start screen accordingly in the StartScreen instead of ContractRecord global variable.

Also check  – https://debajmecrm.com/how-to-dynamically-show-the-start-screen-of-an-app-in-power-apps-canvas-apps/

Hope it helps..

 

Advertisements

Using addProperty to dynamically add a custom property to a JSON object – Power Automate


Recently while working on the integration of Facebook Lead Ads with CRM, through Webhooks / Power Automate we had to process the lead data and create lead and contact records.

Below is a sample format in which we’d get the lead data for the FB form having a first name, last name, date of birth, and email fields in it.

Now we want to create an object having name as proprety and value from values like below from the above response, which will make it easy for use to refer in add a new row / update a row Dataverse step.

For this we will be using addProperty function.

Below is our sample flow –

First we are initializing varJSON – string variable with the JSON response

Than intializing the another variable varFieldData as type Object

Parse JSON action using the sample response.

Here we are interested in field_data property

So in the next step, we loop through each field_data, than use addProperty function in Compose to add name and value to the varFieldData object, and use the outputs of compose to set the varFieldData variable.

addProperty function – addProperty(variables(‘myObject’), ‘newProperty’, ‘propertyValue’)

In the next step, we can see the varFieldData and the way we can access the property last_name added to it.

On running the flow we can see the result as expected –

Hope it helps..

Advertisements