Keyword as argument for another keyword


(Jelina Korhecz) #1

Matrix Version: 5.3

I’m having an issue using a keyword as the argument for another keyword.

Example of my keyword values:

%asset_write_permission_assetid% = 123, 456, 789
%globals_user_assetid% = 147

Conditional statement I’m using:

%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%

(This returns false, which is correct.)

Am I doing something incorrectly, or is this not possible? I looked at Using Keyword Replacement Values as Modifier Arguments but couldn’t see how to use it here.

Use case

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.


(Nick Papadatos) #2

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


(Peter McLeod) #3

Hi
Could also try the ‘Asset Access to List’ settings on the asset listing instead of using conditions (or with some conditions for an extra level of customisation the asset listing settings don’t handle)?
https://matrix.squiz.net/manuals/asset-listing/chapters/details-screen#Asset-Selection
Thanks
Peter


(Bart Banda) #4

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: https://matrix.squiz.net/manuals/concepts/chapters/server-side-javascript#processing-order

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?


(Jelina Korhecz) #5

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.


(Bart Banda) #6

In 5.4 you can achieve this using Server Side JS, so maybe once your system has been upgraded you could revisit this and implement it that way?