-
Notifications
You must be signed in to change notification settings - Fork 0
/
CRUD_FLS_CheckUtility
36 lines (32 loc) · 1.4 KB
/
CRUD_FLS_CheckUtility
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public with sharing class CRUD_FLS_CheckUtility {
public static Boolean checkReadAccess(String [] fieldsToRead, Map<String,Schema.SObjectField> m) {
for (String toRead : fieldsToRead) {
// Check if the user has read access on the each field
if (!m.get(toRead).getDescribe().isAccessible()) {
return false;
}
}
return true;
}
public static Boolean checkCreateAccess(String [] fieldsToCreate, Map<String,Schema.SObjectField> m ){
for (String toCreate : fieldsToCreate) {
// Check if the user has create access on the each field
if (!m.get(toCreate).getDescribe().isCreateable()) {
return false;
}
}
return true;
}
public static Boolean checkUpdateAccess(String [] fieldsToUpdate, Map<String,Schema.SObjectField> m ){
for (String toUpdate : fieldsToUpdate) {
// Check if the user has update access on the each field
if (!m.get(toUpdate).getDescribe().isUpdateable()) {
return false;
}
}
return true;
}
public static Boolean checkDeleteAccess(Schema.DescribeSObjectResult m){
return m.isDeletable();
}
}