• Samuel Woldu

Validating a comma delimited list using Power Apps

If your requirement is to build a Power App that allows users to submit a validated CDL then this article should help.


I have found that there is nothing 'quite of the box' when using Power Apps that allows you to validate a comma delimited list (CDL) provided by an end user. This is a common requirement given that end users might prefer to copy and paste a list instead of selecting multiple items. For this example, I'm using the Azure Adventure Works sample database. We will go through all the steps to ensure end users can only submit a CDL of product codes if all the values provide exist in the SalesLT.Product table.


Before diving into the solution let’s think about what we want Power Apps to do and break it into different steps:

1) Take the CDL and turn it into an array of values

2) Confirm the values provided are in a valid format

3) Confirm the values provided exist in the data source

4) If step 3 and step 4 are validated then allow them to submit the CDL or the array of values


Step 1, 2 and 3

Create collections based on the users input text which can be used to determine if the values provided are in the correct format and if they exist in the product list. I used the code below in the Onchange property of the user input text



The reason why the logic has been split into 2 separate collections is that the product code column data type in the SalesLT.Product table is an integer and if the user provides text string as part of the CDL I've found the collection do not build correctly as the SQL query will fail when trying to convert the varchar(string) into an integer. Example below.



Step 4)


Using the collections that have been created you can determine if all the rows are in the expected format, and if the values provided are existing product codes to set the visibility, display mode or OnSelect properties of a submit button (or anything else really).

Code below for a button used to submit the CDL.



Here's a Power App template where I've imported the CDL into the Power App locally.

Have a play with it and let me know what you think.


If you have questions please leave a comment below.


Sam











229 views0 comments