+ Start a Discussion
GYAN ANDRUSGYAN ANDRUS 

Hi Pls Anyone help for this ....I want to assign a value for Colors,I have a Custom object called item order,In that object i have field called Color__c,I want to assign the code in another custom field for each color

I am not giving any color code in record,I need to  get   the color  code dynamically .Please tell me how to acheive tiz
if Color__c = Pink
Color Code =780,

Like this i have  50 Color,How to acheive this
David Catindoy 101David Catindoy 101
Use list custom settings for this one. Here's a sample link (http://blog.jeffdouglas.com/2010/01/07/using-list-custom-settings-in-salesforce-com/) that might be helpful.
GYAN ANDRUSGYAN ANDRUS
Thanks David, I have created the custom Settings,Can you please tell How to get code Dynamically and save the code in Records?

trigger ColorCodes on PBSI__PBSI_Item__c (after insert,after update) {
    
Map<string,Item_Master_Color__c> mapCodes = Item_Master_Color__c.getAll();
    
}

 I am  struggling,,Please help me......
 
David Catindoy 101David Catindoy 101
Step 1:
User-added image

Step 2:
User-added image

Step 3:

trigger ColorCodes on PBSI__PBSI_Item__c (before insert, before update) {
    
     Map<String, Item_Master_Color__c> mapCodes = Item_Master_Color__c.getAll();
     
     for(PBSI__PBSI_Item__c item : Trigger.new){
         if(item.Color__c != null && mapCodes.containsKey(item.Color__c)){
             item.Color_Code__c = mapCodes.get(item.Color__c);
         }
     }
}
GYAN ANDRUSGYAN ANDRUS
Thank you So much for this..but i got error

trigger ColorCodes on PBSI__PBSI_Item__c (before insert, before update) {
    
     Map<String, Item_Master_Color__c> mapCodes = Item_Master_Color__c.getAll();
     
     for(PBSI__PBSI_Item__c item : Trigger.new){
         if(item.Color__c != null && mapCodes.containsKey(item.Color__c)){
             item.Color_Code__c = mapCodes.get(item.Color_Code__c);
         }
     }
}
Item_Master_Color__c Custom setting object ,I have  the Code API name is  Color_Code__c

ERROR:Illegal assignment from Item_Master_Color__c to String
David Catindoy 101David Catindoy 101
Try this:
 
trigger ColorCodes on PBSI_PBSI_Item__c (before insert, before update) {
    
     Map<String, Item_Master_Color__c> mapCodes = Item_Master_Color__c.getAll();
     
     for(PBSI_PBSI_Item__c item : Trigger.new){
         if(item.Color__c != null && mapCodes.containsKey(item.Color__c)){
             item.Color_Code__c = mapCodes.get(item.Color__c).Color_Code__c;
         }
     }
}