• SOURAV GUHA 9
  • NEWBIE
  • 15 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 9
    Replies
Scenario:- Create a Map with cityName as key,and its corresponing
======    places as values

Public class Map_Practice{
public static void mapPrac(){
    //*Create a Map with cityName as key,and its corresponing places as values
    Map<string,list<string>> myMap = new Map<string,list<string>>();
        list<string> Hplaces = new list<string>{'SRnagar','LBnagar','KBHP'};
        list<string> Bplaces = new list<string>{'Marthali','Ecity','Whitefield'};
        list<string> Cplaces = new list<string>{'Thambaram','ChromePet','TNnagar'};
            myMap.put('HYD',Hplaces);
               myMap.put('BAN',Bplaces);
            myMap.put('CHE',Cplaces);
        system.debug('City and Its Places'+myMap);
        //Get all the city names
        set<string> keys =myMap.keySet();
         system.debug('Cityes==>'+keys);
        //get all the places
        /* *if my map of values is list<string> then we can get all the values list<list<string>>*/
        list<list<string>> values = myMap.values();
           system.debug('Places==>'+values);  
        } 

}

Please Help Me i am new to salesforce
HandlerClass:-
==========
public class PreventConDuplicatePhoneByAccount {
    public static void fetchDupCon(list<contact> conList){
        for(contact c:conList){
            integer count=[select count() From Account WHERE id=:c.accountId and Phone=:c.Phone];
            if(count!=1){
                c.Phone.addError('Phone No Should Be Same As Linked Account');
            }
        }
    }
}

Trigger  Code:-
==========
trigger PreventConDuplicatePhoneByAccountTrigger on Contact (before insert,before update) {
PreventConDuplicatePhoneByAccount.fetchDupCon(Trigger.new);
}
 
on Lead creation and updation if lead status is qualified or unqualified want current date . i have written below trigger but its not working

trigger LeadTrigger on Lead (before insert,Before update) {
   if(trigger.isBefore && trigger.isUpdate){
LeadTriggerHandler.befUpdt(trigger.new , trigger.oldMap);
   }

}
------------------------------------------------------------------------------------
public class LeadTriggerHandler {
    
    public static void befUpdt(List<Lead> newLd, map<Id,Lead> oldMapLd){
        
        for(Lead ld : newLd){
           if (oldMapLd != Null && ld.status != oldMapLd.get(ld.Id).status ){
                if(ld.status == 'qualified' && ld.status ==' unqualified'){
                    ld.CreatedDate = system.now() ;
                }
            }
        }
        
    }

}

thank you,
snehal
1.Contact has Picklist values of
>>Status = Draft ,Open,Closed 
2.Account has three fields 
>>No.of .Open Contacts
>>No.of.Closed Contacts
>>No .of .Draft contacts 
write a Apex trigger to update the number of draft ,open,closed contacts on Account field  ,based on contact status .
 
I have a list of permission sets (PS1-10) and one profile. Below are the steps which I need to execute:
  • First I need to find the users who have this particular profile and PS7
  • Then I need to check if the users having PS7 and this profile have all the permission sets (PS1-10) assigned to them. 
  • If there are less permission sets assigned, then return Missing, if there are more permission sets assigned, return Additional, else return No Change. I need to implement this using either Flow or Apex. 
  • The final output should give me the userID, the permission sets assigned to them and Missing/Additional/No change
Till now I have been doing this manually by querying the PermissionSetAssignment object, then retrieving the Assignee details and the permission sets assigned to the assignee, then manually checking.
 
Thank you