function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kshannonkshannon 

Problem Triggering Double -> Integer

Hey I'm trying to write a trigger on the one record we have Years for the term. The other one we have months for the term.

 

What I tried doing is:

 

double newmonths;

 

for(Contract c : contractrecords){

        newmonths = o.Term_Yrs__c * 12;

 

c.ContractTerm = newmonths;

 

Error: Compile Error: Illegal assignment from Double to Integer

 

How would one accomplish changing the type so that I can do the math and enter it in properly?

 

Message Edited by kshannon on 03-19-2010 08:34 AM
Best Answer chosen by Admin (Salesforce Developers) 
kshannonkshannon

Hey thanks I got it by doing o.Term_Yrs__c.intvalue();

 

Thanks.

All Answers

imuinoimuino

Try doing

 newmonths = Double.valueOf(o.Term_Yrs__c * 12);

kshannonkshannon

Hey thanks I got it by doing o.Term_Yrs__c.intvalue();

 

Thanks.

This was selected as the best answer
dbirlemdbirlem

imuino wrote:

Try doing

 newmonths = Double.valueOf(o.Term_Yrs__c * 12); 


 
I've had nothing but nightmares with formulas following this syntax. I would recommend to move the multiplier out, and use a function to calculate that.