Adapting this example slightly, here's a function that would allow you to query this privilege (and a few others, for good measure):
function getUserPrivileges() {
var privileges = database.queryAccessPrivileges(context.getUser().getDistinguishedName());
return {
createDocuments: ((privileges & NotesDatabase.DBACL_CREATE_DOCS) > 0),
deleteDocuments: ((privileges & NotesDatabase.DBACL_DELETE_DOCS) > 0),
readPublicDocuments: ((privileges & NotesDatabase.DBACL_READ_PUBLIC_DOCS) > 0),
writePublicDocuments: ((privileges & NotesDatabase.DBACL_WRITE_PUBLIC_DOCS) > 0)
};
}
If you add the above to a script library, then any code that references that library could include logic like the following:
if (getUserPrivileges().deleteDocuments) {
// delete something…
}
For additional flexibility, you could adjust the getUserPrivileges()
function to be passed a handle on the specific database the user is trying to delete from instead of always assuming it's the current.