Recently in one of our flows, we were getting the below error –
InvalidTemplate. Unable to process template language expressions in action ‘List_rows_:_Region’ inputs at line ‘0’ and column ‘0’: ‘The template language function ‘replace’ expects its first parameter ‘string’ to be a string. The provided value is of type ‘Null’. Please see https://aka.ms/logicexpressions#replace for usage details.’.
One or more fields provided is of type ‘Null’, a different type is expected.
This was because the replace function that we were using for the Filter rows property of List Rows (Dataverse) had the variable value as null.
Below was our dynamics expression where we replaced apostrophe with 2 single quotes – https://nishantrana.me/2023/02/27/how-to-handle-single-quote-apostrophe-in-filter-rows-in-power-automate-dataverse/
The solution was to use coalesce function, to replace null with a blank string as shown below.
Similarly, we can use coalesce function to provide a default value.
The coalesce function will evaluate its arguments in order and will return the first non-blank or non-empty value. If all the arguments are blank or empty strings, the function will return blank.
After using the coalesce function, our flow was successful.
More on COALESCE
A similar example in SQL –
Hope it helps..