CHT API
Introduced in v3.12.0
Provides CHT-Core Framework’s functions to contact summary, targets and tasks. The API is available in the cht
reserved variable under the v1
version.
Function | Arguments | Description |
---|---|---|
hasPermissions(permissions, userRoles, chtPermissionsSettings) | permissions : String or array of permission name(s).userRoles : (Optional) Array of user roles. Default to the current logged in user.chtPermissionsSettings : (Optional) Object of configured permissions in CHT-Core’s settings. Default to the current instance’s configured permissions. | Returns true if the user has the permission(s), otherwise returns false. |
hasAnyPermission(permissionsGroups, userRoles, chtPermissionsSettings) | permissionsGroups : Array of groups of permission name(s).userRoles : (Optional) Array of user roles. Default to the current logged in user.chtPermissionsSettings : (Optional) Object of configured permissions in CHT-Core’s settings. Default to the current instance’s configured permissions. | Returns true if the user has all the permissions of any of the provided groups, otherwise returns false. |
getExtensionLib(name) | name : String of script name | Returns an executable function identified by the given name configured as extension-libs. |
CHT API’s code samples
const canEdit = cht.v1.hasPermissions('can_edit');
const canManagePlaces = cht.v1.hasPermissions(['can_create_places', 'can_update_places']);
const hasAnyGroup = cht.v1.hasAnyPermission([
['can_view_messages', 'can_view_message_action'],
['can_view_reports', 'can_verify_reports']
]);
const averageFn = cht.v1.getExtensionLib('average.js');
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified 06.04.2023: 1008 - Fix Partials (#1009) (4938b3e)