• Shital
  • NEWBIE
  • 5 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies

Hello Guys,

Hope you all are safe!!

I want to show users name and when the user is added to particular group on lighting page.
First part I am able to display users name and to display users added date I need your help

This code is showing all the users added in public group/Queue so along with this name of users I would like to show when the user is added to grp/queue

public with sharing class HRM_GetQueueMembers_ctlr {   
    @AuraEnabled
    public static List<Group> getQueue(){ //this function fetches all the queues
        List<Group> QueueList = [Select Name,CreatedDate from Group where type='Queue' and DeveloperName like 'HRM%' ORDER BY Name ASC];
        system.debug('---QueueList'+QueueList);
        return QueueList;
    }
    
    @AuraEnabled
    public static List<User> getQueueMembers(Id QueueId){ //this function fetches queue members        
        List<GroupMember> publicGroupList = [Select UserOrGroupId from GroupMember where GroupId=:QueueId];
        system.debug('---publicGroupList'+publicGroupList);
        List<Id> listGroupId = new List<Id>();
        List<User> MemberList = new List<User>(); 
        List<Id> listOfUsersId=new List<id>();
        
        try{
            for(GroupMember gm:publicGroupList){                
                string mId = gm.UserOrGroupId;
                if(mId.left(3)=='005'){ //If first 3 char of UserOrGroupId are '005' then it is a user
                    listOfUsersId.add(mId);
                }else if(mId.left(3)=='00G'){ //If first 3 char of UserOrGroupId are '00G' then it is a group
                    listGroupId.add(mId);
                }
            }
            
            //while(listGroupId.size()>0)
             //This loop will run untill there are public groups inside public groups(removed while loop due to sonar cube issue)
                List<GroupMember> MemberIds = [Select UserOrGroupId,SystemModstamp from GroupMember where GroupId=:listGroupId];
                listGroupId.clear();
               
                for(GroupMember m : MemberIds){
                    string mId = m.UserOrGroupId;
                   
                    if(mId.left(3)=='005'){ //If first 3 char of UserOrGroupId are '005' then it is a user
                        listOfUsersId.add(mId);
                        //listofUsersId.add(D);
                    }else if(mId.left(3)=='00G'){ //If first 3 char of UserOrGroupId are '00G' then it is a group
                        listGroupId.add(mId);
                    }
                }
            
             
            if(listOfUsersId.size()!=0){
                List<User> u = [Select Name, profile.Name, UserRole.Name from User where Id in:listOfUsersId ];
                if(u.size()>0){
                    MemberList.addAll(u);
                } 
            }
        }
        catch(Exception e){
            e.getStackTraceString();
        }
        return MemberList;
    }
}

Any thoughts or help will be much appriciated!!

Hi All,

We are creating one lead at a time from operation custom object on some conditions met I want to do owner assignment in such way that if
1) existing operation BD Name is A then created lead from that operation record should goes to A,If BD name on operation record is B then lead goes to B and BD name on operation  is C then lead goes to C and 2) if BD name is other than A,B,C then lead goes to sequential among these three A,B,C .

For example, If BD Name on operation record is X then that lead goes to A,If BD name on operation is Y then Lead goes to B, BD name on operation is Z lead goes to C , BD Name on Operation is Q again lead goes to A and like wise

I have tried below code:
This code is working for First Scenario but for Second scenario it is Assigning first user in the list to every leads

global class SendMailtoLeadCreatedFromOperation{
    
    map<String,id> tempMap = new map<String,id>();
      
    global list<id> distributedInuserIDList = new list<id>();
   
    global SendMailtoLeadCreatedFromOperation(){
        tempMap = fetchOwnerForAssignment();
        system.Debug('---tempMap Map---'+ tempMap);
    }
    
    
    public void OwnerAssignment(list<Lead> ownerassignlist){
        
        system.debug('---ownerassignlist---'+ownerassignlist);
        
        list<User> distributedUsersList = [Select id,name from User where Website_Services__c = true];
         system.debug('---distributedUsersList---'+distributedUsersList+'---Size distributedUsersList---'+distributedUsersList.size());
        
        for(User temp : distributedUsersList){
            distributedInuserIDList.add(temp.id);
          }
         system.debug('---distributedInuserIDList---'+distributedInuserIDList);
          
          for(Lead scheduledoperation : ownerassignlist){
          
               if(tempMap.containskey(scheduledoperation.BDE_Name__c)){ 
                  
                  scheduledoperation.OwnerID = tempMap.get(scheduledoperation.BDE_Name__c);
                  scheduledoperation.User__c = tempMap.get(scheduledoperation.BDE_Name__c);
                     
                     
                }else{
                    
                    scheduledoperation.OwnerID = distributedInuserIDList.get(0);
                    scheduledoperation.User__c = distributedInuserIDList.get(0);
                     
                    system.debug('---ownerid is---'+scheduledoperation.OwnerID); 
                                     
                    distributedInuserIDList.add(scheduledoperation.User__c);
                    distributedInuserIDList.remove(0);
                    }
                    system.debug('---distributedInuserIDList contain---'+distributedInuserIDList+'---distributedInuserIDList SIZE---'+distributedInuserIDList.size());
            }   
    }
    
   
     public map<String,String> fetchOwnerForAssignment(){
    
        list<WebInternalLeadOwnerAssignmentCS__c> csList = [Select BDE_Name__c,UserId__c
                                                             from WebInternalLeadOwnerAssignmentCS__c
                                                             where isActive__c =: true];  
        system.debug('----csList---'+csList+'--csList size--'+csList.size()); 
        
        
            for(WebInternalLeadOwnerAssignmentCS__c temp : csList){
                if(tempMap.containskey(temp.BDE_Name__c))
                    tempMap.get(temp.BDE_Name__c);
                    else
                     tempMap.put(temp.BDE_Name__c,temp.UserId__c);
            }
            system.debug('----tempMap---'+tempMap+'--tempMap size--'+tempMap.size());
            return tempMap;
    }
    
 }



Can anyone help if possible
  • December 04, 2018
  • Like
  • 0
I need to send mails to those leads who has not opened first email which I have already sent to them...
How can I achieve it??   Through HTML status report (Unopened) filed I got those clients who didn't open an email...But how can I get those clients throgh query??

plz help  
  • April 19, 2018
  • Like
  • 0
global class NewAMCLeadsForCampaign {
    
    @future (callout = true)
    public static void execute(){
        
            Http http = new Http();
            
            HttpRequest request = new HttpRequest();
            
            request.setEndpoint('http://www.startupwala.in/salseforce_automization/get_json_of_dummy_company_data.php');
            request.setMethod('POST');
            
            HttpResponse response = http.send(request);
            
            system.debug('-----response---'+response);
            
            map<String,Object> ResponseMap = (map<String,Object>)JSON.deserializeUntyped(response.getBody());
            
            system.debug('----ResponseMap-----'+ResponseMap);
            
            list<Object> objList = (list<Object>)ResponseMap.get('companies_data');
            system.debug('----objList-----'+objList);
            
            map<Integer,map<String,Object>> LeadDetailsMap = new map<Integer,map<String,Object>>();
            
            map<String,Object> InnerMap = new map<String,Object>();
            
            list<String> strList = new List<String>();
            
            list<Lead> LeadList = new list<Lead>();
            
            map<String,String> getCustomSettingMap = new map<String,String>();
                
            Integer i = 1; 
            for(Object tempOp : objList){
                
                InnerMap = (map<String,Object>)tempOp;
                LeadDetailsMap.put(i,InnerMap);
                i++;
                system.debug('----Inside LeadDetailsMap----'+LeadDetailsMap);
                system.debug('----InnerMap----'+InnerMap);
            }
            
            system.debug('----LeadDetailsMap----'+LeadDetailsMap);
            
            if(ResponseMap.get('companies_data') != null){
            
            list<Object> objectList = (list<Object>)ResponseMap.get('companies_data');
            
            Integer index = 0;
            
            for(Integer temp : LeadDetailsMap.keySet()){
                
                map<String,Object> LeadInfoMap = LeadDetailsMap.get(temp);
                
                Lead newLead = new Lead();
                
                   newLead.Company_Class__c = string.valueof(LeadInfoMap.get('company_class'));
                
                newLead.CIN__c = string.valueof(LeadInfoMap.get('corporate_identification_number'));
                
                newLead.FirstName = string.valueof(LeadInfoMap.get('first_name'));
                
                newLead.LastName = string.valueof(LeadInfoMap.get('last_name'));
                
                newLead.Company = string.valueof(LeadInfoMap.get('company_name'));
                
                newLead.Email = string.valueof(LeadInfoMap.get('email_id'));    
                
                newLead.City_of_Office__c = string.valueof(LeadInfoMap.get('city_of_office'));
                
                newLead.Company_Type__c = string.valueof(LeadInfoMap.get('company_type'));
                
                newLead.Enquiry_For__c = 'MCA Email Campaign';
                 
                 
                String str = string.valueof(LeadInfoMap.get('date_of_incorporation'));
                 
                newLead.Status = 'Open';
                string str1 = str.replace('-','/');
                 
                system.debug('---str1---'+str1);
                 
                Date dt = Date.parse(str1);
        
                system.debug('---dt---'+dt);
                
                newLead.Date_of_Incorporation__c = dt;
                
                           
                system.debug('-----newLead------'+newLead);                
                    
                LeadList.add(newLead);
                
                }
                
            system.debug('----LeadList----'+LeadList);
            
                if(LeadList.size() > 0){
                    
                    insert LeadList;
                    
                    system.debug('----LeadList----'+LeadList);
                }
            }
            
            
    }            
    
}
  • March 30, 2018
  • Like
  • 0
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        
        query = 'select id,Name,enquiry_For__c,email,Contact__c,ownerId,CCEmail__c from Lead'+
                'where enquiry_For__c = \'MCA Email Campaign\' AND (X3rdDayOfIncorporation__c =: todayDate OR X5th_Day_of_Incorporation__c =: todayDate'+
                'OR X7th_Day_of_Incorporation__c =: todayDate OR X10th_Day_of_Incorporation__c =: todayDate OR X15th_Day_of_Incorporation__c =: todayDate'+
                'OR X20th_Day_of_Incorporation__c =: todayDate OR X30th_Day_of_Incorporation__c =: todayDate OR X35th_Day_of_Incorporation__c =: todayDate'+
                'OR X45th_Day_of_Incorporation__c =: todayDate OR X50th_Day_of_Incorporation__c =: todayDate OR X60th_Day_of_Incorporation__c =: todayDate'+
                'OR X75th_Day_of_Incorporation__c =: todayDate OR X85th_Day_of_Incorporation__c =: todayDate OR X100th_Day_of_Incorporation__c =: todayDate'+
                'OR X120th_Day_of_Incorporation__c =: todayDate OR X130th_Day_of_Incorporation__c =: todayDate OR X150th_Day_of_Incorporation__c =: todayDate'+
                'OR X180th_Day_of_Incorporation__c =: todayDate)';
                
                system.debug('--query--' +query);
                
                return Database.getQueryLocator(query);
    }
 
  • March 12, 2018
  • Like
  • 0
Hi All,

We are creating one lead at a time from operation custom object on some conditions met I want to do owner assignment in such way that if
1) existing operation BD Name is A then created lead from that operation record should goes to A,If BD name on operation record is B then lead goes to B and BD name on operation  is C then lead goes to C and 2) if BD name is other than A,B,C then lead goes to sequential among these three A,B,C .

For example, If BD Name on operation record is X then that lead goes to A,If BD name on operation is Y then Lead goes to B, BD name on operation is Z lead goes to C , BD Name on Operation is Q again lead goes to A and like wise

I have tried below code:
This code is working for First Scenario but for Second scenario it is Assigning first user in the list to every leads

global class SendMailtoLeadCreatedFromOperation{
    
    map<String,id> tempMap = new map<String,id>();
      
    global list<id> distributedInuserIDList = new list<id>();
   
    global SendMailtoLeadCreatedFromOperation(){
        tempMap = fetchOwnerForAssignment();
        system.Debug('---tempMap Map---'+ tempMap);
    }
    
    
    public void OwnerAssignment(list<Lead> ownerassignlist){
        
        system.debug('---ownerassignlist---'+ownerassignlist);
        
        list<User> distributedUsersList = [Select id,name from User where Website_Services__c = true];
         system.debug('---distributedUsersList---'+distributedUsersList+'---Size distributedUsersList---'+distributedUsersList.size());
        
        for(User temp : distributedUsersList){
            distributedInuserIDList.add(temp.id);
          }
         system.debug('---distributedInuserIDList---'+distributedInuserIDList);
          
          for(Lead scheduledoperation : ownerassignlist){
          
               if(tempMap.containskey(scheduledoperation.BDE_Name__c)){ 
                  
                  scheduledoperation.OwnerID = tempMap.get(scheduledoperation.BDE_Name__c);
                  scheduledoperation.User__c = tempMap.get(scheduledoperation.BDE_Name__c);
                     
                     
                }else{
                    
                    scheduledoperation.OwnerID = distributedInuserIDList.get(0);
                    scheduledoperation.User__c = distributedInuserIDList.get(0);
                     
                    system.debug('---ownerid is---'+scheduledoperation.OwnerID); 
                                     
                    distributedInuserIDList.add(scheduledoperation.User__c);
                    distributedInuserIDList.remove(0);
                    }
                    system.debug('---distributedInuserIDList contain---'+distributedInuserIDList+'---distributedInuserIDList SIZE---'+distributedInuserIDList.size());
            }   
    }
    
   
     public map<String,String> fetchOwnerForAssignment(){
    
        list<WebInternalLeadOwnerAssignmentCS__c> csList = [Select BDE_Name__c,UserId__c
                                                             from WebInternalLeadOwnerAssignmentCS__c
                                                             where isActive__c =: true];  
        system.debug('----csList---'+csList+'--csList size--'+csList.size()); 
        
        
            for(WebInternalLeadOwnerAssignmentCS__c temp : csList){
                if(tempMap.containskey(temp.BDE_Name__c))
                    tempMap.get(temp.BDE_Name__c);
                    else
                     tempMap.put(temp.BDE_Name__c,temp.UserId__c);
            }
            system.debug('----tempMap---'+tempMap+'--tempMap size--'+tempMap.size());
            return tempMap;
    }
    
 }



Can anyone help if possible
  • December 04, 2018
  • Like
  • 0
I need to send mails to those leads who has not opened first email which I have already sent to them...
How can I achieve it??   Through HTML status report (Unopened) filed I got those clients who didn't open an email...But how can I get those clients throgh query??

plz help  
  • April 19, 2018
  • Like
  • 0
Hello, I got a question for retriving data. For example, if I use code like this: <apex:outputtext value="{!Case.Owner.Name}" /> and I can get a text show on my web page. But how can I know where does each value after dot come from, is that simply (object name) . (field name) . (data wanna retrive). But how can I know the exact name of data that I wanna retrive?  The example I showed is a bad example, cuz I assume that the name of data I wanna retrive maybe call Name, yet I dont know where to find it.     Thanks for helping.
Hi guys.. I want to integrate facebook on salesforce.i want to know the process regarding this.
I want to fetch some data regaring the user..
pls tell me what things are required as i am using REST api.