• Shailesh Chaudhary
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
Is it right way to create public group?

A public group comprises a group of individual users, other groups ,individual roles, or roles with subordinates and all having a common function. You can define sharing rules with the public rules in Salesforce. The public groups can extend sharing rules beyond the role hierarchies. The user logs into Salesforce for creating a new public group and then navigates to   (Credit: AnavClouds Software)

Administer-> Manage Users->Public Groups. 
When we create a new Salesforce user, the user must be assigned to a new public group, depending on the user country. 
Add the user to the right public group with the following steps: 
Create a trigger for the User object and call the method AddUser belonging to the class named AddUsersToPublicGroups in afterInsert. 
Use the Trigger.new context variable to pass the user record. 
For an already existing user record with a new country, it should be added to the newly added public group, removing it from the previous public group along with the country. 
Next, call the updateUser method of the class AddUserstoPublicGroup in afterUpdate and use the Trigger.new and Trigger.old context variables for passing the User Record. 
Create a class AddUsersPublicGroups and write the below code. 

public class AddUsersToPublicGroups {
public static void addUser(list<User> user){
    List<GroupMember> listGroupMember =new List(); 
    for(User u : user){
    String division = u.Division; 
        if(!String.isBlank(division)){
        String groupname ='PublicGroup'+division;
            list<Group> group1 = [select id,name from Group where Name=:groupname and type='regular'];
            GroupMember gm= new GroupMember(); 
            gm.GroupId=group1[0].id;
            gm.UserOrGroupId = u.id;
            listGroupMember.add(gm);
        }
    }
    insert listGroupMember;
}
    public static void updateUser(list oldversion,list newversion){
        List<GroupMember> listGroupMember =new List<GroupMember>();
        list<groupMember> groupm = new list<groupMember>();
        for(user oldu :oldversion){
            for(user newu : newversion){
                String olddivision = oldu.Division;
                String newdivision = newu.Division;
                group group2 = [select id,name from Group where Name=:'PublicGroup'+olddivision and type='regular'];
                if(olddivision!=newdivision){
                    GroupMember gm= new GroupMember(); 
            gm.GroupId=group2.id;
               gm.UserOrGroupId = newu.id;
                    String gid = gm.GroupId;
                    String userid = gm.UserOrGroupId;
               listGroupMember.add(gm);
                    groupm = [select Id from GroupMember where  GroupId=:gid and UserOrGroupId=:userid];
                }
            }
        }
        
try{
         delete groupm;
        }catch(DmlException ex){
         ex.getMessage();
        }
        
adduser(newversion);
    }
}


I have created a new lightening button on Lead list view - page. When i click on this button, two fields values should per set, one being pick field and another is Checkbox.
Below is what i tried and it did not work

/lightning/o/Lead/new?defaultFieldValues= Lead_Type__c = (!URLENCODE(‘Qualified’)) Accepted_Checkbox__c = 'True'

Please suggest!

Hi All

How can i integrate salesforce with WhatsApp .I am not sure it is possible by REST/SOAP .
Hello,

I have created an inbound email handler that processes XML email body. The email will be triggered by a third party application directly to Salesforce's email handler id. These emails are not being processed by Salesforce. However, Salesforce processes the email sent from my email account.

Also, I have my email domain and the third party app's email domain names in the Accept Email From setting.

I have set the failure scenario configuration as shown below:
Email Services Failure Configuration


I need help in finding out if the emails are actually being received by Salesforce.

-Vijay