Chris Simon
03/31/2022, 9:32 AM//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
});
var stSublistPermission = stPaymentRecordPermission <= 1 ? serverWidget.FieldDisplayType.INLINE : serverWidget.FieldDisplayType.ENTRY;
log.debug('DEBUG', 'User: ' + JSON.stringify(objUser));
log.debug('DEBUG', 'Permission Level for LIST_CUSTRECORDENTRY' + stCustomRecordTypeId + ':' + stPaymentRecordPermission);
battk
03/31/2022, 10:56 AMbattk
03/31/2022, 10:57 AMbattk
03/31/2022, 10:58 AMChris Simon
03/31/2022, 11:52 AMbattk
03/31/2022, 11:57 AMChris Simon
03/31/2022, 12:05 PMbattk
03/31/2022, 12:24 PMChris Simon
03/31/2022, 12:52 PMbattk
03/31/2022, 12:54 PMbattk
03/31/2022, 12:55 PMChris Simon
03/31/2022, 1:24 PM//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']);
var stSublistType = serverWidget.SublistType.LIST;
var stSublistPermission = serverWidget.FieldDisplayType.INLINE;
log.debug('DEBUG', 'Custom Record Permission Results: ' + JSON.stringify(arrPermissionSearchResults));
for(var intPermissionIndex = 0; intPermissionIndex < arrPermissionSearchResults.length; intPermissionIndex++)
{
var stPaymentRecordPermissionLevel = arrPermissionSearchResults[intPermissionIndex].getValue({name: 'level'});
log.debug('DEBUG', 'Permission Level for ' + stCustomRecordTypeId + ':' + stPaymentRecordPermissionLevel);
if(stPaymentRecordPermissionLevel > 1)
{
stSublistType = serverWidget.SublistType.INLINEEDITOR;
stSublistPermission = serverWidget.FieldDisplayType.ENTRY;
log.debug('DEBUG', 'Permission Granted!');
}
break;
}
battk
03/31/2022, 1:28 PMbattk
03/31/2022, 1:28 PMbattk
03/31/2022, 1:29 PMbattk
03/31/2022, 1:30 PMbattk
03/31/2022, 1:30 PM