In Salesforce, there are times when we need to put a group of users in a team to implement the following key features:
1. Set the default shared access via sharing rule;
2. Share the records with other users;
3. Specify the synchronized contacts, the onwer of these contacts belong to other user;
4. Assign the user in the group to the specified actions, such as the approval process.
Group as the system table whose field information is as follows:
Where type is the picklist field, his value can be taken out by schema mode.
PublicWith sharingclassGrouppicklist { Public StaticList<string>getgrouppicklist () {Schema.describefieldresult Grouptyperesult=Group.Type.getDescribe (); List<Schema.PicklistEntry> grouptypepicklistvalues =grouptyperesult.getpicklistvalues (); List<String> grouptypevalues =NewList<string>(); for(Schema.picklistentry grouptypepicklistvalueitem:grouptypepicklistvalues) {Grouptypevalues.add (groupType Picklistvalueitem.getvalue ()); } returngrouptypevalues; }}
After the call, the results are as follows:
["Allcustomerportal", "Collaborationgroup", "manager", "Managerandsubordinatesinternal", "Organization", " Prmorganization "," Queue "," Regular "," Role "," Roleandsubordinates "," roleandsubordinatesinternal "," Sharingrulegroup "," Territory "," Territoryandsubordinates "]
The result shows that group can have many kinds of type. Where the type of the public group corresponds to the type of Regular,queue is the queue. When you take a group of the corresponding type, you only need to add a search condition.
In addition to the Group table, another system table--groupmember needs to be introduced. This table is used to store information about a group's corresponding member or subgroup, with the main fields: GroupId, Id,userorgroupid.
Application:
1. Query the user or group contained in the public group of the CEO group
SELECT from where inch (Selectfromgroupwhere='CEO Group' and = ' Regular ')
2. When group is part of the approval process, the query is currently processed for approval by the public group
list<group> grouplist = [select Id from group where Name = ' CEO Group '];if(Grouplist! =NULL&& grouplist.size () > 0) {Id groupId= Grouplist.get (0). Id; List<ProcessInstance> PiS =[SELECT targetobjectid from ProcessInstance WHERE i Sdeleted=falseand ID in (SELECT processinstanceid from Proc Essinstanceworkitem WHERE isdeleted=falseand Actorid =: groupId)]; if(Pis.size () > 0) {System.debug (' Current group user approval '); }}
Summary: Group in the record sharing and as the approval process of the approver often use, master the relevant basic information can be very good operation, if there are errors in the place to welcome criticism, if there are questions welcome message.
Salesforce 0 Basic Learning (41) Group