i saw this expression in one of the Pipeine , in the filter activity condition. can anyone help me understad this expresson used( you can refrase inorder to make it understandable). looks difficult to understand.
@if(equals(pipeline().parameters.FileName,'default'),endswith(toUpper(item().name),'.PDF'),
and(startswith(item().name,replace(string(pipeline().parameters.Filemane),'*.txt','')),
endswith(toUpper(item().name),'.PGP')))
Thanks
I dont have blocker , but i cannot understand the Expression. Just wanted to get some clarity what is the purpose of that code , what are they trying to achieve in that particualar filter condition in the ADF
If you use the above expression in the filter activity. It will filter the values of the array based on the
FileName
parameter.This is my sample array of file names:
For you the array will be an array of objects. that's why in the above expression it's there as
item().name
. For me it's onlyitem()
.Filter activity filters based on the condition. If the particular array item satisfies the condition(true/false) then it filters it.
In the above expression, If the
FileName
parameter value is'default'
, it filters the items which are ending with.PDF
.if(condition,True case,else case)
so in true case we are checkingendswith()
.PDF
or not. If it is true, then filter condition is true and that particular array value will be filtered.else case
If the parameter value is
correct*.txt
(other than default). In this case it replaces the'*.txt'
with empty strings('') and returns'correct'
. Then it checks(first condition) the whether the array value starts with'correct'
and endswith.PGP
(second condition). If both conditions are true, then filter condition is true and array value is filtered.This is a sample demo:
Array:
Filter with same condition:
for me it's only
item()
notitem().name
.If I take the parameter value as
'default'
.Filter output array (
all .PDF files
):If I take the parameter value as
'correct*.txt'
.Filter output array(
.PGP files starts with 'correct'
):NOTE: If your parameter value is only like
'correct.txt'
then use'.txt'
in the expression.