Salesforce 0 Basic Learning (41) Group

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.