You need to sign in to do that
Don't have an account?
GYAN ANDRUS
Hi Pls Anyone help....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
if Color__c = Pink
Color Code =780,
Like this i have 50 Color,How to acheive this
Color Code =780,
Like this i have 50 Color,How to acheive 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;
}
}
}
ERROR:loop variable must be sobject..Please help me
All Answers
You can retrieve the values from Custom Object and store them in a Map.
This you can write it in a Utility Class with a static variable so that you don't need to retrieve every time.
Please do let me know if it helps you.
Regards,
Mahesh
But the color code is not entering anywhere,I need to create tthe Code
If the Colour code is not entered anywhere then how can we get the color codes?
If you can explain more about requirement, it will be easy to provide the solution.
Regards,
Mahesh
If map key contains value,i need to take that value and using trigger i need to update the code in the filed,pls help
Use custom list settings and try try something like 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;
}
}
}
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;
}
}
}
ERROR:loop variable must be sobject..Please help me
Map<Integer, String> m = new Map<Integer, String>{5 => 'Jon', 6 => 'Quinton', 1 => 'Reid'}; ---Like tiz