Hide view if logged in user is in a field? #574
-
|
Hey folks, I am trying to use _hsv to hide a view if the logged in user is not in a particular connection field. (Connects to the "user" table, a.k.a. accounts.) Here is my current attempt, which is not working. _hsv=[ktlCond, not, ktlLoggedInAccount, field_62, view_306] The expected logic would be "if the currently logged in user is not equal to the value in field_62 of view_306 then true" and the field is hidden. It isn't working. I haven't found much (any) documentation on how ktlLoggedInAccount is supposed to be used, so I need help. If there is a better approach I would also love to hear it, because this is just the first case. I will ultimately want to compare to a second field and a role. Right now I am just trying to get the proof of concept working. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
|
Oops! I am using the wrong keyword. I will research and repost. If someone wants to suggest something then that would be nice. :) |
Beta Was this translation helpful? Give feedback.
-
|
Hi Don, You're right, the documentation of ktlLoggedInAccount is lacking. It has fallen between two chairs. This is how it's supposed to be used:
field_6 is the Name field in the Accounts table. But I just discovered a bug that cause this to malfunction, never showing the view if the condition is not met. Anyways, this is not even what you try to achieve, due to the connected field. This is not supported yet. In the meantime, for those who want to hide a view based on the logged-in user, you can use this, which does the same thing:
Put it in the view you want to hide. About your request, I'd need to study the feasibility and how hard it would be to do it. I can't commit to anything for now. Norm |
Beta Was this translation helpful? Give feedback.
-
|
Further testing this morning - @cortexrd UPDATE: I better understand how ktlLoggedInAccount works. It is essentially fulfilling the function that "view" would normally have, telling the keyword to look at the specified field on the logged in user's account record. (Not anything on the page being rendered.) Therefore, using the original sample code: _cls=[ktlHidden], [ktlCond, has, Norm, field_6, ktlLoggedInAccount] This hides the view whenever the logged in user name contains "Norm" regardless of anything on the page being rendered. My testing proved this to function as expected in my application. Victory! Now... to get ktlCond to test against a field on the page--the PM connection field_62--I tried using ktlRefVal as below: _cls=[ktlHidden], [ktlCond, not, ktlRefVal, field_1, ktlLoggedInAccount], [ktlRefVal, field_62, view_306] (The referenced "field_1" is the Name field on my accounts table, and it works when I use it to mimic the sample code.) I expected this to hide the view if the logged in user name is not the user name returned by field_62 (the PM field) of view_306 (a details view on the page being rendered.) This doesn't happen. The statement always hides the view regardless of the contents of field_62, view_306. For example, in my test the PM was Kevin McDonald and the logged in user was Kevin McDonald (me) and the view did not show. I tested with a project where I am not the PM and it also did not show the view. So... am I using ktlRefVal wrong? Is ktlRefVal not supported with _cls? Or is my entire approach wrong? I am trying to ensure that only the PM (And eventually a few others like the owner.) can see the view in question. (Which contains an 'update project' button.) |
Beta Was this translation helpful? Give feedback.
-
|
Hi @kpmcdona63, I think there's a misunderstanding about what ktlLoggedInAccount does in its current form. It's designed to check field values on the logged-in user's Account record, not to compare the logged-in user against values displayed in page views. The only reason for the field_6 to be required is because there's no way for the KTL to guess what the Name field is, without you telling it specifically. What you're trying to do (show a view only if the logged-in user matches a Project Manager connection field on the page) isn't currently supported by this keyword. For your other questions, ktlRefVal and ktlLoggedInAccount simply don't work together as is. This would require some code changes. To be honest, I can't commit to anything right now - too busy. But I recommend you try with AI, as this is certainly something not too difficult to do for it. I Claude Code and it works beautifully. Norm |
Beta Was this translation helpful? Give feedback.
Hi @kpmcdona63,
I think there's a misunderstanding about what ktlLoggedInAccount does in its current form. It's designed to check field values on the logged-in user's Account record, not to compare the logged-in user against values displayed in page views. The only reason for the field_6 to be required is because there's no way for the KTL to guess what the Name field is, without you telling it specifically.
What you're trying to do (show a view only if the logged-in user matches a Project Manager connection field on the page) isn't currently supported by this keyword.
For your other questions, ktlRefVal and ktlLoggedInAccount simply don't work together as is. This would require some code…