You need to sign in to do that
Don't have an account?
Prema -
My requirement is whenever a field on Lead called State(Picklist field) has any value, if it gets saved then a Territory field should be auto populated(Value should be saved automatically for example State=Gujrat then Territory=India). I have a custom settings called Country_List and there is a field called Country__c. Inside Country I have defined States and it's country. How can i achieve this, Please help me.Thanks in advance
Hello Friends please help me how can i get my country value from custom settings inside Leads field called Territory.
trigger GetTerritoryIfStateSaved on Lead (before insert,before update) { List<Lead> lead1=new List<Lead>(); public string stateget; if(Trigger.isInsert||Trigger.isUpdate) { for(Lead leadc:Trigger.new) { if(leadc.States__c!=null) { for (Countries_List__c cl: Countries_List__c.getAll().values()) { Countries_List__c.add(cl.Country__c); } } } for(Lead AllLeads:trigger.new) { if(Countries_List__c.contains(AllLeads.States__c)) { //AllLeads.adderror('Oops!!! All routing numbers must go to real banks'); AllLeads.Territory__c=Countries_List__c.Country__c.; } } } }
My requirement is whenever a field on Lead called State(Picklist field) has any value, if it gets saved then a Territory field should be auto populated(Value should be saved automatically for example State=Gujrat then Territory=India). I have a custom settings called Country_List and there is a field called Country__c. Inside Country I have defined States and it's country. How can i achieve this, Please help me.Thanks in advance
All Answers
Replace State__c filed with States which is standard filed . Complete code is here