• Don Barnes 5
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hi - I am trying to copy the converted currency amount on opportunity to a custom field.  My purpose for doing this is to use the custom field in another trigger to roll up information to the Top Level Account - I can't use SF roll up features because we use multi-currency and dated exchange rates - at this point I am not concerned about the dated exchange rates - but as I say it limits what I can in SF.  

 

I am very new to Apex Code but have given it a bash, I have the following code - which does work - however I have it on before update and therefore it is taking the amount value from the opportunity - I really need to either change this to an after update trigger or modify my code to look at the new value.  I get an error when I change to after update saying that the record is read only.  If someone is able to point me in the right direction, it would be much appreciated.  Thank you.

 

trigger CopyConvertedValue on Opportunity (before update) {

 

Integer i = 0;
Opportunity Oppy = Trigger.new[i];

String intTest = Trigger.new[i].ID;

//Step 2. Create a list of Opps
List<Opportunity> Oppys = [Select convertCurrency(Amount)From Opportunity where ID =: intTest];

for (Opportunity Opp : oppys)


//Step 3. Update Oppy
Trigger.new[i].Converted_Value__c = Trigger.new[i].Amount;
}

  • January 16, 2012
  • Like
  • 0

Hi - I am trying to get the color value associated with a PicklistEntry. I've written some logic that gets the PicklistEntry, but I am not sure if there is a way to get the color associated with that entry using the Apex field describe methods. Can someone help me out or confirm that this isn't possible? (It looks like it is part of the metadata API, but I can't find any documentation on using it in Apex.)

 

 

Map<String, Schema.SObjectType> globalDescribe = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> objectFields = globalDescribe.get('Campaign').fields.getMap();
Schema.DescribeFieldResult fieldInfo = objectFields.get('Type');

if(fieldInfo.getType() == 'Picklist' || fieldInfo.getType() == 'MultiPicklist') {
for(Schema.PicklistEntry pe : fieldInfo.getPicklistValues()) {
// Instead of getValue(), is there a getColor() method? pe.getValue();
}
}