Skip to content

Instantly share code, notes, and snippets.

View ankushsomani09's full-sized avatar

Ankush Somani ankushsomani09

  • Bangalore
View GitHub Profile
@ankushsomani09
ankushsomani09 / gist:82bbb9d60a0032c00e630e8f417e2fb1
Last active July 6, 2020 04:54
Find Active, Inactive and Total users per Role-vise across salesforce Org
//Find use of Role across active/inactive users
List < User > lstUsers = [Select Id, IsActive, ProfileId, UserRoleId from user where UserRoleId != null];
map < String, Integer > mapGroupToInActive = new Map < String, Integer > ();
map < String, Integer > mapGroupTotal = new Map < String, Integer > ();
for (User objUser: lstUsers) {
if (!objUser.IsActive) {
if (mapGroupToInActive.containsKey(objUser.UserRoleId))
mapGroupToInActive.put(objUser.UserRoleId, mapGroupToInActive.get(objUser.UserRoleId) + 1);
else
mapGroupToInActive.put(objUser.UserRoleId, 1);
@ankushsomani09
ankushsomani09 / GroupUsersCalculation.java
Created July 6, 2020 05:04
Find Active, Inactive, Total user in Groups across salesforce org
List < Group > lstGroupReg = [Select Id from Group where Type = 'Regular'];
List < User > lstInActiveUser = [Select Id from user where IsActive = false];
Set < id > SetInactiveUser = new Set < id > ();
for (User objUser: lstInActiveUser) {
SetInactiveUser.add(objUser.id);
}
List < GroupMember > lstGM = [Select Id, UserOrGroupId, GroupId from GroupMember where GroupId IN: lstGroupReg];
//system.debug(lstGM.size());
map < String, Integer > mapGroupToInActive = new Map < String, Integer > ();
//To Mark/Check Read only field
var arrayRead = document.querySelectorAll('input[id$=fls_read_ck]');
for(i=0;i<arrayReadOnly.length;i++){
if(!arrayReadOnly[i].checked){
arrayReadOnly[i].checked = true;
}
}
//To Mark/Check Edit field