Renovation
Search…
.perm

.hasPerm()

To check if the user has permission for a particular event.

Input

HasPermParams
property
type
required
description
doctype
string
yes
The target doctype
ptype
PermissionType
yes
The permission type to check
permLevel
number
no
The permission level (0-9)
docname
string
no
The target docname

Output

Promise<boolean>*
If there are errors, false is returned.

Example

async-await
1
const permission = await renovationInstance.perm.hasPerm({
2
doctype: "System Settings",
3
ptype: PermissionType.read
4
});
5
if (permission) {
6
// Permitted
7
console.log("Permitted");
8
} else {
9
// Not Permitted
10
console.log("Not Permitted");
11
}
Copied!
Classic Promise
1
renovationInstance.perm
2
.hasPerm({
3
doctype: "System Settings",
4
ptype: PermissionType.read
5
})
6
.then(permission => {
7
if (permission) {
8
// Permitted
9
console.log("Permitted");
10
} else {
11
// Not Permitted
12
console.log("Not Permitted");
13
}
14
});
Copied!

.hasPerms()

To check for the list of permissions against a doctype.

Input

HasPermsParams
property
type
required
description
doctype
string
yes
The target doctype
ptype
PermissionType[]
yes
The list of permissions to check
docname
string
no
The target docname

Output

Promise<boolean>*
If there are errors, false is returned. If one permission is false, then false is returned.

Example

async-await
1
const permission = await renovationInstance.perm.hasPerms({
2
doctype: "User",
3
ptypes: [PermissionType.read, PermissionType.write, PermissionType.create]
4
});
5
if (permission) {
6
// Permitted
7
console.log("Permitted");
8
} else {
9
// Not Permitted
10
console.log("Not Permitted");
11
}
Copied!
Classic Promise
1
renovationInstance.perm
2
.hasPerms({
3
doctype: "Customer",
4
ptypes: [PermissionType.read, PermissionType.write, PermissionType.create]
5
})
6
.then(permission => {
7
if (permission) {
8
// Permitted
9
console.log("Permitted");
10
} else {
11
// Not Permitted
12
console.log("Not Permitted");
13
}
14
});
Copied!

.getPerm()

To get the permission based on the DocMeta.

Input

GetPermParams
property
type
required
description
doctype
string
yes
The target doctype
doc
RenovationDocument
no
Optionally pass the document to get the document specific permissions

Output

Array<Partial<Permission>>>
Partial indicates not all properties of Permission are necessarily defined.

Example

async-await
1
const getPermResult = await renovationInstance.perm.getPerm({
2
doctype: "Renovation Review"
3
});
4
if (getPermResult.success) {
5
// Number of permissions: 1
6
console.log("Number of permissions: ", getPermResult.data.length);
7
// Can read: false
8
console.log("Can read", getPermResult.data[0].read);
9
} else {
10
// If the permissions have an error
11
console.log("Error", getPermResult.error);
12
}
Copied!
Classic Promise
1
renovationInstance.perm
2
.getPerm({
3
doctype: "Renovation Review"
4
})
5
.then(getPermResult => {
6
if (getPermResult.success) {
7
// Number of permissions: 1
8
console.log("Number of permissions: ", getPermResult.data.length);
9
// Can read: false
10
console.log("Can read", getPermResult.data[0].read);
11
} else {
12
// If the permissions have an error
13
console.log("Error", getPermResult.error);
14
}
15
});
Copied!

.canCreate()

To check if user can create a document.

Input

CanCreateParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canRead()

To check if user can read a document.

Input

CanReadParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canWrite()

To check if user can write a document.

Input

CanWriteParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canCancel()

To check if user can cancel a document.

Input

CanCancelParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canDelete()

To check if user can delete a document.

Input

CanDeleteParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canImport()

To check if user can import a document.

Input

CanImportParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canExport()

To check if user can export a document.

Input

CanExportParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

canPrint()

To check if user can print a document.

Input

CanPrintParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canEmail()

To check if user can email a document.

Input

CanEmailParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canSearch()

To check if user can search a document.

Input

CanSearchParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canGetReport()

To check if user can get report of a doctype.

Input

CanGetReportParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canSetUserPermissions()

To check if user can change other users' permissions.

Input

CanSetUserPermissionsParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canSubmit()

To check if user can submit a document.

Input

CanSubmitParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canAmend()

To check if user can amend a document.

Input

CanAmendParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*

.canRecursiveDelete()

To check if user can delete recursively.
Recursive deleting is the deleting of the linked documents before the deleting of the targeted document.

Input

CanRecursiveDeleteParams
property
type
required
description
doctype
string
yes
The target doctype

Output

Promise<boolean>*
Last modified 1yr ago