To check if the user has permission for a particular event.
HasPermParams
property | type | required | description |
doctype | string | yes | The target doctype |
ptype |
| yes | The permission type to check |
permLevel | number | no | The permission level (0-9) |
docname | string | no | The target docname |
Promise<boolean>
*
If there are errors, false
is returned.
async-await
const permission = await renovationInstance.perm.hasPerm({doctype: "System Settings",ptype: PermissionType.read});if (permission) {// Permittedconsole.log("Permitted");} else {// Not Permittedconsole.log("Not Permitted");}
Classic Promise
renovationInstance.perm.hasPerm({doctype: "System Settings",ptype: PermissionType.read}).then(permission => {if (permission) {// Permittedconsole.log("Permitted");} else {// Not Permittedconsole.log("Not Permitted");}});
To check for the list of permissions against a doctype.
HasPermsParams
property | type | required | description |
doctype | string | yes | The target doctype |
ptype |
| yes | The list of permissions to check |
docname | string | no | The target docname |
Promise<boolean>
*
If there are errors, false
is returned. If one permission is false
, then false
is returned.
async-await
const permission = await renovationInstance.perm.hasPerms({doctype: "User",ptypes: [PermissionType.read, PermissionType.write, PermissionType.create]});if (permission) {// Permittedconsole.log("Permitted");} else {// Not Permittedconsole.log("Not Permitted");}
Classic Promise
renovationInstance.perm.hasPerms({doctype: "Customer",ptypes: [PermissionType.read, PermissionType.write, PermissionType.create]}).then(permission => {if (permission) {// Permittedconsole.log("Permitted");} else {// Not Permittedconsole.log("Not Permitted");}});
To get the permission based on the DocMeta.
GetPermParams
property | type | required | description |
doctype | string | yes | The target doctype |
doc |
| no | Optionally pass the document to get the document specific permissions |
Array<Partial<Permission>>>
Partial
indicates not all properties of Permission
are necessarily defined.
async-await
const getPermResult = await renovationInstance.perm.getPerm({doctype: "Renovation Review"});if (getPermResult.success) {// Number of permissions: 1console.log("Number of permissions: ", getPermResult.data.length);// Can read: falseconsole.log("Can read", getPermResult.data[0].read);} else {// If the permissions have an errorconsole.log("Error", getPermResult.error);}
Classic Promise
renovationInstance.perm.getPerm({doctype: "Renovation Review"}).then(getPermResult => {if (getPermResult.success) {// Number of permissions: 1console.log("Number of permissions: ", getPermResult.data.length);// Can read: falseconsole.log("Can read", getPermResult.data[0].read);} else {// If the permissions have an errorconsole.log("Error", getPermResult.error);}});
To check if user can create a document.
CanCreateParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can read a document.
CanReadParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can write a document.
CanWriteParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can cancel a document.
CanCancelParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can delete a document.
CanDeleteParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can import a document.
CanImportParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can export a document.
CanExportParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can print a document.
CanPrintParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can email a document.
CanEmailParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can search a document.
CanSearchParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can get report of a doctype.
CanGetReportParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can change other users' permissions.
CanSetUserPermissionsParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can submit a document.
CanSubmitParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can amend a document.
CanAmendParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*
To check if user can delete recursively.
Recursive deleting is the deleting of the linked documents before the deleting of the targeted document.
CanRecursiveDeleteParams
property | type | required | description |
doctype | string | yes | The target doctype |
Promise<boolean>
*