Aaron R
01/29/2025, 10:06 PMCeligo AI
01/29/2025, 10:06 PMAI generated answer (using internal Slack threads):To pull the ID field for a permission name, you can use the
runtime.getCurrentUser()
method to get the current user's permissions. Then, you can use the getPermission()
method to get the permission level for a specific permission.
Here is a sample code snippet:
javascript
//Get User Permissions
var objUser = runtime.getCurrentUser();
//Get the environment internal ID for the custom record in the environment
var objCustomRecord = record.create({
type: 'customrecord_test'
});
var stCustomRecordTypeId = objCustomRecord.getValue({fieldId: 'rectype'});
var stPaymentRecordPermission = objUser.getPermission({
name: 'LIST_CUSTRECORDENTRY' + stCustomRecordTypeId
});
log.debug('DEBUG', 'Permission Level for LIST_CUSTRECORDENTRY' + stCustomRecordTypeId + ':' + stPaymentRecordPermission);
However, if you want to check the user's permissions for a specific custom record, you might need to perform a role search. Here is a sample code snippet:
javascript
//Get User Permissions
var objUser = runtime.getCurrentUser();
log.debug('DEBUG', 'User: ' + JSON.stringify(objUser));
//Get the environment internal ID for the custom record in the environment
var objRecord = record.create({
type: 'customrecord_test'
});
var stCustomRecordTypeId = 'LIST_CUSTRECORDENTRY' + objRecord.getValue({fieldId: 'rectype'});
log.debug('DEBUG', 'Custom Record Permission Desired: ' + stCustomRecordTypeId);
var arrFilters = [];
arrFilters.push(search.createFilter({name: 'internalid', operator: 'anyof', values: [objUser.role]}));
arrFilters.push(search.createFilter({name: 'permission', operator: 'anyof', values: [stCustomRecordTypeId]}));
log.debug('DEBUG', 'Custom Record Permission Filters: ' + JSON.stringify(arrFilters));
var arrPermissionSearchResults = commonUtil.search('role', null, arrFilters, ['permission','level']);
log.debug('DEBUG', 'Custom Record Permission Results: ' + JSON.stringify(arrPermissionSearchResults));
Remember, the permission level returned by getPermission()
is based on the user's role, not the user's individual permissions. If you need to check the user's individual permissions, you might need to perform a user search instead.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
01/29/2025, 10:07 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.81637907
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.803299546
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.795738578
Celigo AI
01/29/2025, 10:07 PM