Add “All” with the Dataverse Choice Field to show in PowerApps

It happened to answer for one of the PowerApps forums to display the dropdown of the word “All” with the Dataverse Choice (OptionSet) field.

When you use SharePoint as a Datasource it’s easy to combine with the word “All” and set the Items property of the dropdown. But when using Dataverse is different

Sharepoint

ClearCollect(
ColAllStatusSP,
{Value: “All”},Choices(SPList.ChoiceName)
);

Dataverse

Initially, I thought the solution will be similar to Sharepoint. But learned it’s not.

Solution: We need to loop through the Dataverse choice values like below

ClearCollect(
ColAllStatus,
{Value: “All”}
);
ForAll(
Choices(GlobalChoiceName).Value,
Collect(
ColAllStatus,
{Value: Text(ThisRecord.Value)}
)
)

Since Choice won’t change frequently, Collect the values on Onvisible property of the screen and use it. In some scenarios, you may need to filter the choice field based on use cases.

Conclusion

To add the word “All” with the Dataverse choice field, we need to loop through the choice field to add to the collection. To improve the performance of the page load, you may use Concurrent.

Leave a Reply

Your email address will not be published. Required fields are marked *