Buy Now
Sign in

owner id as a var

emmexx , November 23 2017
Answered
E
emmexx
I don't understand how to use the owner id field with a variable.

I want to let only the user that created a record, edit it.
In the edit event / Permission owner id field I tried to put a function or a var that should retrieve the user_id from the table. But how can I put "something" that returns a value in that field if there's no function that can do that in CC6 (to my knowledge).

I created a php function that retrieves the user_id of a record and returns the value but:

{fn:get_user_id} doesn't work
{var:get_user_id} doesn't work
{fn:get_user_id}{var:get_user_id}

The function works in other contexts (if I put {fn:get_user_id}{var:get_user_id} in the content field of the event I get the user_id).

What is the right way to accomplish that?

Thank you
maxx
admin
Hi maxx,

In the "owner id value" field you need to provide the value of the record owner which is going to be matched against the value of the logged in user id, so if you are trying to apply this in an "edit record" form then you could use {var:read_data.model.user_id_field_name} in the "owner id value"

Best regards
Max
If your main question got answered then please mark the answer using the button!​

Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
E
emmexx
"admin":

In the "owner id value" field you need to provide the value of the record owner which is going to be matched against the value of the logged in user id, so if you are trying to apply this in an "edit record" form then you could use {var:read_data.model.user_id_field_name} in the "owner id value"

That's what I did but probably I used a wrong syntax.
I had to put the user id in the url and used {data:user_id} in owner id value.
I'll try again.

Thank you
maxx
admin
Hi maxx,

If this is an "event" then it may not work because the event permissions are checked before the functions inside the event are processed, the "read_data" data would only be available to a function or view after the "read_data"

Best regards
Max
If your main question got answered then please mark the answer using the button!​

Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!