Balance comparison is giving me different results in different places

Hello!

I have a formula field, Balance__c, that returns a currency of 2 decimal places. Displaying the field in a table for this particular record, the balance is 0. I have a button that conditionally renders if the balance is 0. The button is showing. I am in the process of creating a mass action, that first does a branch to see if {{Balance__c}} != 0 then shows an error message saying it “must be 0 first.” This branch keeps triggering despite the other two indicators behaving as if the balance is 0. I tried adding a branch that checks if {{Balance__c}} == 0 instead and it did not trigger. Do branches behave differently and/or did I mess up that logic?

Thanks!

I have a hypothesis, but let me know if this is true:

The difference between the scenarios is that the Mass Action’s action sequence doesn’t have or cannot check the context for the field to do the comparison while the field in the row and the button both do have a context.

How does context work with mass actions in terms of a comparison check or a field update?

Thanks!

Hey @nkovash and welcome :smiley:!

Have you tried modifying the following to:
{{Balance__c}} != "0"

Cheers,

Hey @Germany! That was a very clever suggestion that I did not think of, I appreciate it. Sadly it didn’t work.

I think I am going to just leave out branching logic from my Mass Actions.

Thanks for the help!

No problem @nkovash!

So to answer your initial question:

How does context work with mass actions in terms of a comparison check or a field update?

Field updates will update all fields in context. Comparison checks would only function on the first row in context, so with that being said:

I have a hypothesis, but let me know if this is true:

The difference between the scenarios is that the Mass Action’s action sequence doesn’t have or cannot check the context for the field to make the comparison while the field in the row and the button both do have a context.

I think it’s both true and false since it checks the context but only for the first row. There is probably a way to do this, but it may be a little more advanced and may require some JS.

If it’s important to the project you’re working on, you could look into doing this check with a combination of adopting the rows in context into a UI model and this aggregation functions.

I hope that helps!

Cheers,

Context in Mass Actions. That is a really good question. Generally the action sequence will be run recursively on each of the rows that have been selected by the user. And the context available for use in your actions via merge syntax will be the active row.

That is interrupted if a new row is created in your action sequence. At that point Context is transffered to the new row - and it stays there even when the iteration goes to the new selected row. There has been a long standing argument internally about this scenario and we don’t have a good sense for how we will ultimately correct it.

For the time being - if you are going to do much sophisticated action processing on some or all rows in your model - we recommend using a code snippet. In Javascript you can be much more explicit about what you what data is being interacted with (on a row by row basis) and what actions you are enabling.

1 Like

Another few thoughts.

A good debugging technique here would be to put a message / block ui action right before your branch - and have it display the value of {{balance__c}}. This will show you what value is being held in context when the branch runs (if any…)

Are you familiar with the action debugging api? IN the browser console type skuid.debug.actions.loggingOn() Then in the console you will see a more detailed inventory of all actions as they occur. (Including the row context).

1 Like