publicstaticStringGetUserIPAddress(){string ReturnValue ='';// True-Client-IP has the value when the request is coming via the caching integration.
ReturnValue = ApexPages.currentPage().getHeaders().get('True-Client-IP');// X-Salesforce-SIP has the value when no caching integration or via secure URL.if(ReturnValue ==''|| ReturnValue ==null){
ReturnValue = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');}// get IP address when no caching (sandbox, dev, secure urls)if(ReturnValue ==''|| ReturnValue ==null){
ReturnValue = ApexPages.currentPage().getHeaders().get('X-Forwarded-For');}// get IP address from standard header if proxy in usereturn ReturnValue;}// GetUserIPAddress
if(!documentIdsList.isEmpty()){// add the document to the unpublished library first.Id internalLibraryId = FDICUtil.getLibraryId('EDOS Community - Unpublished Files');ContentWorkspace internalLib =[Select Id FROM ContentWorkspace WHERE NAME ='EDOS Community - Unpublished Files'];if(internalLibraryId !=null){// link the file to the unpublished library by default. When the order gets published the file will be// shared with t he published library. We can remove the share with the public library but we can't remove it from// the unpublished library since that was the first library the file was shared with. By defualt the first library// the document gets linked to is the owner of that library, so link it to the unpublished library first.for(Id docId: documentIdsList){//ContentWorkspaceDoc cwd = new ContentWorkspaceDoc(ContentDocumentId = docId, ContentWorkspaceId = internalLibraryId);ContentWorkspaceDoc cwd =newContentWorkspaceDoc(ContentDocumentId = docId, ContentWorkspaceId = internalLib.Id);
addToLibraryList.add(cwd);}}if(!addToLibraryList.isEmpty()){insert addToLibraryList;}}
GET A LIST OF ALL RELATED OBJECTS FROM A PARENT OBJECT
Set results =newSet();for(ChildRelationship r:Case.SObjectType.getDescribe().getChildRelationships()){
results.add(string.valueOf(r.getChildSObject()));}system.debug(string.join(newList(results),', '));
//Get list of what limits are available.List<System.OrgLimit> limits = OrgLimits.getAll();for(System.OrgLimit aLimit: limits){System.debug('Limit Name '+ aLimit.getName());}Map<String,System.OrgLimit> limitsMap = OrgLimits.getMap();System.OrgLimit dataStorageLimit = limitsMap.get('DataStorageMB');System.OrgLimit fileStorageLimit = limitsMap.get('FileStorageMB');// Max and usage limit values of dataStorageLimitSystem.debug('dataStorageLimit Value: '+ dataStorageLimit.getValue());System.debug('Maximum Limit: '+ dataStorageLimit.getLimit());// Max and usage limit values of fileStorageLimitSystem.debug('fileStorageLimit Value: '+ fileStorageLimit.getValue());System.debug('Maximum Limit: '+ fileStorageLimit.getLimit());
GET NUMBER OF USERS ASSIGNED TO EACH PERMISSION SET
SELECT PermissionSet.Name,Count(Id)FROM PermissionSetAssignment
WHERE Assignee.isActive =trueAND PermissionSet.IsOwnedByProfile =falseGROUPBY PermissionSet.Name
ORDERBYCount(Id)DESC
GET NUMBER OF USERS ASSIGNED TO EACH PROFILE
SELECTcount(Id), Profile.Name
FROM User
GROUPBY Profile.Name /* NOTE: make sure to filter by active users if you want only active users */
EXPORT OBJECT LEVEL PERMISSIONS FOR ALL PROFILES AND PERMISSION SETS - DATA LOADER
EXPORT FIELD LEVEL SECURITY FOR ALL PROFILES AND PERMISSION SETS - DATA LOADER
SELECT Parent.Profile.Name, Parent.Label, Parent.IsOwnedByProfile, SobjectType, Field, PermissionsEdit, PermissionsRead
FROM FieldPermissions
ORDERBY Parent.Profile.Name, Parent.Label, SobjectType, Field
GET LIST OF APPS
SELECT Id, ApplicationId, Name, Label, Type FROM AppMenuItem WHERE type='TabSet'/* NOTE: remove where clause to see all application types (Network, Connected Apps, etc.). TabSet is for Salesforce Apps created for users */
GET LIST OF PROFILES WITH ACCESS TO APPS
SELECT Id, SetupEntityId, ParentId, Parent.Label, Parent.IsCustom, Parent.IsOwnedByProfile, Parent.ProfileId, Parent.Profile.Name
FROM SetupEntityAccess
WHERE SetupEntityType ='TabSet'AND Parent.IsOwnedByProfile =trueORDERBY Parent.ProfileId