Hello everyone,
there have already been some discussions on how to build an if condition that does nothing when false. However those Solutions do not seem to work for my case. Maybe you have some ideas to help me with this:
The request seems to be quite simple: If a certain colum(Actiontype) as a defined value do some calculations and put them into an other colum (Sum1). The Actiontype defines which sum colums (sum1-4) have to be updated. The sum colums already have some calculated values.
I am using the Dataverse Connector but anyways I though this should work: Solved: do nothing in if function - Power Platform Community (microsoft.com)
If eq(Actiontype),2, calculate and update sum1, do nothing
if(equals(triggerBody()['number']),2,variables('SummeEtat'))
if(equals(triggerBody()['number']),2,variables('SummeEtat'),)
if(equals(triggerBody()['number']),2,variables('SummeEtat'),'')
which either is not recognizes as a valid expression or promts this error:
Unable to process template language expressions in action 'Update_Controlling_Position_Etat_ANF_Prod' inputs at line '0' and column '0': 'The template language function 'equals' expects two parameters: the values to test for deep equality. The function was invoked with '1' parameter(s). Please see https://aka.ms/logicexpressions#equals for usage details.'.
I have tried puting the current value of the field into the false condition but since the current value comes from one apply to each container and the if condition is in another apply to each container I get another error that the first apply to each has to be superior to the second one which is understandable.
So maybe anyone has another idea on how to form an expression that updates a value if true and simply does nothing to the existing value if false.
Thank you in advance
Solved! Go to Solution.
It is failing because your equals() functions are a little bit off, @TimFe, if you don't mind me saying.
This is what you currently have in that first if() statement, and I've fanned it out so you can see:
|
What you have there is an equals statement without its second parameter. Your other two are similarly (but not the same) just a little off (I've fanned them in the below spoiler):
If #2 also has a bad equals, but the end of the if has an extra comma which infers more should be there: |
|
If #3 is perhaps probably closest to what you're after, here, you wish it to be empty or null on the false branch. It just still has the bad equals 😉: |
|
So, using your 3rd if() as a basis, this would run correctly:
|
All that was done was moving that ',2' inside the equals(). Now it will check to see if triggerBody()['number'] is equal to 2 ... then it will pass the variable 'SummeEtat' if it is 2, and nothing if it isn't.
Plus, as @tom_riha, mentioned, you can also use null. Just make sure that the input you're entering null into is able to accept a null value. 👍 ... @tom_riha wrote:
Hello @TimFe, I'd try two ideas: 1. use null value
2. keep the original value
e.g.
|
Hello @TimFe ,
I'd try two ideas:
1. use null value
if(equals(triggerBody()['number']),2,variables('SummeEtat'),null)
2. keep the original value
if(equals(triggerBody()['number']),2,variables('SummeEtat'),<the current value>)
e.g.
if(equals(triggerBody()['number']),2,variables('SummeEtat'),triggerBody()['number'])
It is failing because your equals() functions are a little bit off, @TimFe, if you don't mind me saying.
This is what you currently have in that first if() statement, and I've fanned it out so you can see:
|
What you have there is an equals statement without its second parameter. Your other two are similarly (but not the same) just a little off (I've fanned them in the below spoiler):
If #2 also has a bad equals, but the end of the if has an extra comma which infers more should be there: |
|
If #3 is perhaps probably closest to what you're after, here, you wish it to be empty or null on the false branch. It just still has the bad equals 😉: |
|
So, using your 3rd if() as a basis, this would run correctly:
|
All that was done was moving that ',2' inside the equals(). Now it will check to see if triggerBody()['number'] is equal to 2 ... then it will pass the variable 'SummeEtat' if it is 2, and nothing if it isn't.
Plus, as @tom_riha, mentioned, you can also use null. Just make sure that the input you're entering null into is able to accept a null value. 👍 ... @tom_riha wrote:
Hello @TimFe, I'd try two ideas: 1. use null value
2. keep the original value
e.g.
|
I found out that the dataverse record is NOT going to be updated (so it's doing nothing) if for the "do nothing case" your formula delivers the same value that the trigger already delivered.
if(equals("do nothing","do nothing"),TriggerFieldContent,else...)
User | Count |
---|---|
88 | |
37 | |
26 | |
13 | |
13 |
User | Count |
---|---|
127 | |
54 | |
37 | |
24 | |
21 |