I need to create a PDM_LIST in HTMPL in which the "where" clause is based on the current role of the logged user. I know I can get the ID of the user by using the tag "$cst.id", so I wonder if there's a similar way to get the current role. If there's not, maybe some alternative method exists. Does anyone knows something regarding this?
Thanks in advance,
Diogo, can you describe what it is you are trying to do? Beyond trying to discern the role of the given user. What content is to be displayed and what should be shown per role?
I ask since it may be easier to take the given content you want to change based on role and apply a dropdown or text field containing that information on each of the roles' form groups, and have the content controlled locally on the text field per form group.
What I wanted is to restrict Personalized Responses based on the role of the user... so, I've created a field for 'role' in the 'response' table, because I could restrict in the PDM_LIST that already exists in request_status_change.htmpl form (and in related forms too). This is the current code:
<PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND cr_flag=1">
Surely, one way to do this is creating a data partition restriction, since I could use "@root.role" structure. However, this would mean I should create this restriction for every partition in every role (current and future ones). And I think, if doing this in HTMPL forms was possible, that would be a more 'elegant' way.
Diogo, $args.QBE.EQ.roleID just come to my mind...maybe you can give this a try(not tested here yet). Thanks _Chi
Hi Chi_Chen, unfortunaltely that didn't work, I believe this was used in some forms of detail_role (or related). But you gave me an idea for searching the string "roleID". And I've found this variable: ahtop.cfgCurrentRoleID. I did some tests and it looks like this is exactly what I was looking for, it brings the ID of the current role.
Diogo, that is cool. Somehow I remember something like that and it seems my memory partially works(lol). Thanks _Chi
You beat me to it. I use this all the time for HTMPL side conditionals.