• yunicfa
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies

hello averybody.

i need someone say me how i can get the description to sobject or field from apex.
there is Schema.DescribeSObjectResult and Schema.DescribeFieldResult but they dont give a method as getDescription().
my best regard! i hope that someone help me with that !

hello everybody.

i need someone say me how i can get the description to sobject or field from apex.
there is Schema.DescribeSObjectResult and Schema.DescribeFieldResult but they dont give a method as getDescription().
my best regard! i hope that someone help me with that !

hello averybody.

 

i need someone say me how i can get the description to sobject or field from apex.

there is Schema.DescribeSObjectResult and Schema.DescribeFieldResult but they dont give a method as getDescription().

my best regard!  i hope that someone help me with that ! 

Here is a trigger I wrote. I understand that I need to get the conversion rate SOQL query out of the for statement:

trigger OpportunityBeforeInsertUpdate on Opportunity (before insert, before update) {


for(Opportunity opp : Trigger.new) {
    if (opp.Total_Amount__c > 0) {
        opp.Amount = opp.Total_Amount__c;
        system.debug('opp amount is ' + opp.Amount);
        } 
    
    
     if(Trigger.isInsert 
     || 
     ((opp.Amount != Trigger.oldMap.get(opp.Id).Amount || opp.CurrencyIsoCode != Trigger.oldMap.get(opp.Id).CurrencyIsoCode)
     &&
     (!opp.IsClosed || (opp.IsClosed && !Trigger.oldMap.get(opp.Id).IsClosed)))
     ||
     (!opp.IsClosed && Trigger.oldMap.get(opp.Id).IsClosed)
     ) 
         {
   double conversionrate = [select conversionrate from CurrencyType where IsoCode = :opp.CurrencyIsoCode];
            opp.Amount_USD__c = opp.Amount/ ConversionRate ;
        }
}
}

 so I wrote the following but still get the Too many SOQL queries error when running a test where 200 opps are inserted:

trigger OpportunityBeforeInsertUpdate on Opportunity (before insert, before update) {

List<CurrencyType> currs = new List<CurrencyType>
([select id, IsoCode, ConversionRate from CurrencyType where IsActive=true limit 200]);

Map<String, Decimal> ConversionRates = new Map<String, Decimal>();

for(integer i=0; i<currs.size(); i++){
ConversionRates.put(currs[i].IsoCode, currs[i].ConversionRate);
}


for(Opportunity opp : Trigger.new) {
    if (opp.Total_Amount__c > 0) {
        opp.Amount = opp.Total_Amount__c;
        system.debug('opp amount is ' + opp.Amount);
        } 
    
    
     if(Trigger.isInsert 
     || 
     ((opp.Amount != Trigger.oldMap.get(opp.Id).Amount || opp.CurrencyIsoCode != Trigger.oldMap.get(opp.Id).CurrencyIsoCode)
     &&
     (!opp.IsClosed || (opp.IsClosed && !Trigger.oldMap.get(opp.Id).IsClosed)))
     ||
     (!opp.IsClosed && Trigger.oldMap.get(opp.Id).IsClosed)
     ) 
         {
            opp.Amount_USD__c = opp.Amount/ ConversionRates.get(opp.CurrencyIsoCode) ;
        }
}
}

 

  • July 04, 2013
  • Like
  • 0

Hi,

 

I want to throw the error message for comments field if everytime Date field is updated

 

I have written the formula below but whenever comments field is not blank it is not working properly.

 

isblank(Comments__c)
&&
ISCHANGED(Date__c)

 

Can anyone help?

hello averybody.

i need someone say me how i can get the description to sobject or field from apex.
there is Schema.DescribeSObjectResult and Schema.DescribeFieldResult but they dont give a method as getDescription().
my best regard! i hope that someone help me with that !

hello averybody.

 

i need someone say me how i can get the description to sobject or field from apex.

there is Schema.DescribeSObjectResult and Schema.DescribeFieldResult but they dont give a method as getDescription().

my best regard!  i hope that someone help me with that !