I have a query that depends on a filter values from powerapps. First of all the flow will be call by powerapps. In the flow all of the following variable initialized as a string value (Request.no, PersonName,Department,RequestType,Status and Priority).
Then I used Compose to write the expression of the query as shown below:
concat(if(not(IsBlank(variables('Request.no'))), concat('Request.no eq ''', variables('Request.no') ,''' and '),''),
if(not(IsBlank(variables('PersonName'))), concat('PersonName eq ''', variables('PersonName') ,''' and '),''),
if(not(IsBlank(variables('Department'))), concat('Department eq ''', variables('Department') ,''' and '),''),
if(not(IsBlank(variables('RequestType'))), concat('RequestType eq ''', variables('RequestType') ,''' and '),''),
if(not(IsBlank(variables('Status'))), concat('Status eq ''', variables('Status') ,''' and '),''),
if(not(IsBlank(variables('Priority'))), concat('Priority eq ''', variables('Priority') ,''''),''))
After that I used Initialize variable with the following expression:
if(endsWith(outputs('Compose'),' and '), trim(outputs('Compose'),sub(length(outputs('Compose')),5), length(outputs('Compose'))), outputs('Compose'))
Then I used Get Items with the output of the compose.
When the user input in powerapps was only for the Req-no as S1 and the other fields he keep them as blank, the query will be:
Request-no = 'S1' and PersonName='' and Department='' and RequestType='' and Status='' and Priority='' and it will return 0 value because no value will have only request number and the other fields empty in it.
So, what I want to do is whenever any field was empty I want to trim the query and to keep the other fields that have values.
So, when the user search only for Request number S1 and the other fields are empty the query will be:
Request-no = 'S1'
When he search for request number and Person name only the query will be:
Request-no='S1' and PersonName='Joe'
How to do this in power automate?
anyone can help me?