Skip to main content

I need to conditionally render a table row action button based on a combination of the running user attribute and a field value in the model.

For example, I have a user with a Role of “A”. I also have a model field value which I can make the same as the Role, “A”.

Can I conditionally render a row action button if the running user’s attribute equals A and the row in the table has a model field equal to A? 


Ben,

Are you asking for one condition: fieldValue = userRole,

Or are you asking for two conditions:

fieldValue = X
userRole = Y

?


If the first, just set your condition so that the field value equals the user role with merge syntax {{$User.userRoleId}} (if you need the actual user Role Name, you’d just need to create a model for the current user, and reference it like so: {{$Model.CurrentUser.data.0.Role.Name}})

If the latter, just add both as rendering conditions and require ALL conditions to be met.


Hey Matt,

Thanks for the response. The second option is what I’m looking for - two conditions - fieldValue = x and userRole = Y. 

“If the latter, just add both as rendering conditions and require ALL conditions to be met.” - that makes sense. However, I just realized a snag in my plan. The userRoile will not be the same value as the model field. It looks like I can’t create a custom field on the user record and use that for rendering conditions. 

Any ideas? I’m completely stuck here. Thanks for any help or feedback.


Ben,

Why can’t you create a custom field on the user object?

If you can provide a more complete description of your use case, we can probably help you find a way.


Why can you not create a custom object on the user record?  is there some “edition limitation” here? 
The custom field will not show up in the list of user attributes always available for conditions,  but you can always get around that if you create a “current user model”  and include the custom field in your model.  Then you can do conditional rendering on that model / field combination in addition to your actual fieldValue. 


Reply