require_once("clients/base/api/CurrentUserApi.php"); class CustomCurrentUserApi extends CurrentUserApi { public function registerApiRest() { //in case we want to add additional endpoints return parent::registerApiRest(); } // override the retrieveCurrentUser function public function retrieveCurrentUser($api, $args) { global $current_user; $current_user_results = parent::retrieveCurrentUser($api, $args); $user_data = $current_user_results['current_user']; // add custom fields here: $user_data['custom_field_c'] = $current_user->custom_field_c; return array('current_user' => $user_data); } }Then from within JavaScript you should be able to access your custom fields via:
app.user.get("custom_field_c");-Mark
Hello,
I have tried to get Full name of user using App.user.get
console.log(App.user.get("full_name"));
It giving me undefined in console.
Any suggestion for this?
One I get full name value then I can go for this solution for custom field.
full_name is retrieved by default so it should be available to you.
Where are you in the application when you try to use it?
I don't think there is a difference between App and app, I use app.user.get('<fieldname>') in the initialize in custom/modules/Cases/clients/base/views/record/record.js and it works for me.
FrancescaS
full_name is retrieved by default so it should be available to you.
Where are you in the application when you try to use it?
I don't think there is a difference between App and app, I use app.user.get('<fieldname>') in the initialize in custom/modules/Cases/clients/base/views/record/record.js and it works for me.
FrancescaS