How to loop all records of a model in the Branch Formula, within SKUID actions?

I need to check the value of an updated field in a SKUID table, and run some actions based on it. As am unable to find a way to refer the edited record, I am trying to loop through all the records while updating and check the field values.

My exact requirement:

When the user tries to update the highlighted ‘Status’ field to ‘Complete-Approved’ or some other specific values manually, I need to block the UI, display a message of ‘Invalid Status’ and revert all the model changes.

The functionality works fine currently, when the user tries to update the first record in the table:

However, it does not work as expected when the ‘Status’ field in other records of the table is updated. 
To achieve this, I was trying to loop through the values in all the records of the table. If any of the values is not expected, I wish to show the ‘Invalid Status’ message and revert back model changes.

The current model actions set for this are shown here, along with the ‘Branch’ formula, which I wish to edit in particular. Instead of the hard-coded value of {{$Model.UwTasks.data.0.Status}} in the formula(which refers to the first record), I need to make this dynamic.

Any help with the issue?

In your branch logic, you’re telling it to only check the first row since you’re referencing it using global merge syntax (($Model.UwTasks.data.0.Status}}. What you probably want is to use contextual/row merge syntax, which would be {{Status}}. 

https://docs.skuid.com/latest/v1/en/skuid/merge-syntax/global-merge-variables.html#global-merge-variables

https://docs.skuid.com/latest/v1/en/skuid/merge-syntax/row-merge-variables.html

1 Like

Hi Matt,

This works for my case!

Thanks a lot!