I wonder if I can generate / update a custom user field with some predefined values based on the role the user is;
For example:
if user Role = Employee --> Update / Generate custom field of all users which are in Role “Employee” with value XX
if user Role = Sales --> Update / Generate custom fields of all users which are in Role “Sales” with value XY
As far as I read script has to be probably in system.roles.update but I don’t know if it’s possible to write user custom fields with server side scripting?
How are you wanting to use this custom value?
It seems that you might instead just want to set a lookup key on the roles themselves. Lookups and System Variables
You’re right. If I could read the look up keys on the roles through the API everything would be fine.
Unfortunately, for the moment it seems that Dreamfactory just displays Global Lookup Keys in the API and no Lookup Keys on Roles - so I’m trying to find a workaround with user specific fields:
I need to customize the look of a App based on Roles (for example supress some inputs where Role has no permissions).
Isn’t there any way to read role specific “Look Up Keys” directly via API?
Sorry I’m a bit confused. Typically to reference a lookup key value you just insert in braces {lookup_key_name}
This works for all types of lookup keys, thought they are hierarchical
Ex: If my user has a lookup named my_lookup and my role also has a lookup named my_lookup, then the value associated with my user takes precedence. Same with global lookups. Most narrow takes precedence.
How are you referencing lookups that it only works globally?
First of all I set global look up keys in Config --> Global Lookup Keys:
test --> 1234
When I call GET /system/config I get the following answer:
…
“lookup_keys”: [
{
“name”: “test”,
“value”: “1234”,
“private”: false,
“id”: null,
“role_id”: null,
“user_id”: null,
“allow_user_update”: null
}
…
If I set Lookup Keys on User or Role I’m not able to receive the values through API.
I could solve this problem with a “dummy table” like [in this post][1] but it’s not a very elegant solution.
@pitw
Took me a bit to track this one down.
Lookups can be pulled through the API for users and roles. They show up as related data, in a value called lookup_keys.
So for example if you wanted to pull the lookup keys for a role whose ID is 3, you would do
GET http://yourbaseurl/rest/system/role/3?related=lookup_keys