You need to sign in to do that
Don't have an account?
Sain
Hi,
My requirement is if i select any picklist value in custome field it has to popup related value on another Picklist field.
Let me explaine in detail, i have two Picklists A and B, If i Selected any value in Picklist A it should has to be update related picklist value in B.
Please share, Does anyone has some sample code or can point me in the right direction?
Many thanks!!!
If i select any picklist value in custome field it has to popup related value on another Picklist field
Hi,
My requirement is if i select any picklist value in custome field it has to popup related value on another Picklist field.
Let me explaine in detail, i have two Picklists A and B, If i Selected any value in Picklist A it should has to be update related picklist value in B.
Please share, Does anyone has some sample code or can point me in the right direction?
Many thanks!!!
trigger PicklistUpdate on MyObject__c (before insert,before update) {
map<string, string> picklistmap=new map<string, string>{'X' => 'x', 'Y' => 'y'};
for(MyObject__c obj:trigger.new){
if(obj.Picklist1__c != null){
obj.Picklist2__c = picklistmap.get(obj.Picklist1__c);
}
}
}
Regards,
Shaik
All Answers
You can use dependant picklist for that. See the article below :
https://help.salesforce.com/HTViewHelpDoc?id=fields_defining_field_dependencies.htm&language=en_US
Jerome
Thanks for ur response.
If we use field dependency we can make visualble of 'B' picklist related values depends on 'A' picklist values, then we have to select manually.
But here my requriement is, 'B' picklist value has to be popup automatically as per value selected in 'A' picklist.
Regards,
Shaik
Is your requirement only for users (UI) or loaded data as well ?
If you have only one possible value of B for every values of A and B is required then it should work fine for UI.
if it is for loaded data as well, you have 2 options depending of the number of values in your picklists.
- option 1: if you do not have a lot of value
you can have a workflow that will populate B based on the value of A.
-option 2 : if you have a lot of values and workflow is not enougth
you'll have to create a custom setting for the dependencies between A and B values and populate B based on A by trigger using the custom setting
Jerome
Both A and B having multiple values.
Yes, we can achieve this by writting trigger.
please share, does you have sample code for this scenario.
Regards,
Shaik
trigger PicklistUpdate on MyObject__c (before insert,before update) {
map<string, string> picklistmap=new map<string, string>{'X' => 'x', 'Y' => 'y'};
for(MyObject__c obj:trigger.new){
if(obj.Picklist1__c != null){
obj.Picklist2__c = picklistmap.get(obj.Picklist1__c);
}
}
}
Regards,
Shaik