%begin_asset_write_permission_assetid^explode:,^in_array:{globals_user_assetid}%
"User is in write permission array."
%else_asset%
"User is not in write permission array."
%end_asset%
This returns true, which is incorrect. However, if I hardcode the user id it works as expected:
%begin_asset_write_permission_assetid^explode:,^in_array:147%
"User is in write permission array."
%else_asset%
"User is not in write permission array."
%end_asset%
I have 10 different groups of approvers, and an asset list that displays all the assets awaiting approval. (Approvers will often have multiple assets to approve and this is designed to help them keep track of them all.)
Rather than making 10 identical asset lists with different permissions for each approver group, I’d hoped that I could use the above in the asset list type format to only show approvers the assets they have access to action — ie. if they are logged in and have write access on the current asset, they have the ability to action it.
Not sure whether I’m giving you the correct information but based on your permissions (your asset listing is displaying) when logged in the user would only see sections that they have access to no? Based on a show_if write access? Show If Design Area
Global keywords are evaluated at the top level, not with each asset being listed in things like asset listings. So the {globals_user_assetid} is not evaluated at that time of when the asset listing type format is processed by each asset being listed, which is why the comparison doesn’t work. Some more info on the processing order here: Server Side JavaScript - Concepts - Manuals | Squiz Matrix 5 Documentation
Just because a user has write access to an asset, doesn’t mean they have are in the workflow step that can approve the asset, so you might need to use the %asset_workflow_current_step_conditions_ids:X% (The asset IDs of the User, User Group and/or Role conditions of the Workflow Step (comma-separated), where X is the asset ID of the Workflow Step.) keyword instead and maybe handle some formatting client side with JS?
Thanks all. I ended up changing the workflow conditions (as @Bart mentioned) however I still couldn’t get the access list to show the approver only the assets they had access to action without duplicating my code/markup.
It’s a pity that it’s not possible to check global variables against other keywords (similar to the way I outlined above) — I know this is a very basic system but checking variables against other variables is also quite a basic programming concept.