0

I am parsing all the number fields as Double.valueOf(value) and storing in Task fields. If the value is Integer then the result of Double.valueOf(value) will be value.0 which is obvious. This case is working for all other custom number field even if the precision is given as Number(8,0) but for field CallDurationInSeconds(number()) I am getting exception Illegal assignment from Double to Integer.

I am not sure why CallDurationInSeconds is handled separately.

Can any one help me out?

0

As far as I know CallDurationInSeconds actually stores int, not double, unlike all the other number fields in Salesforce. Not sure why it's made this way though.

Here's some documentation on it: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_task.htm

I found no other place it says anything about storing integer there though.

| improve this answer | |
0

I could not find Double.parseDouble(value) in double class definition and when i used this i got this error:- Method does not exist or incorrect signature: void parseDouble(Integer) from the type Double

so, i used valueOf(stringToDouble) which Returns a Double that contains the value of the specified String. As in Java, the String is interpreted as representing a signed decimal.

Illegal assignment from Double to Integer because You may be storing the double value in Integer variable.May be somehow like this:-

Task allTasks = [select id,CallDurationInSeconds from task limit 1 ];
system.debug(allTasks);
allTasks.CallDurationInSeconds=8;
update allTasks;
Integer d=double.valueof(allTasks.CallDurationInSeconds); //throwing the same exception
system.debug(d);

But when i tried with double variable it does not throw any exception:-

Task allTasks = [select id,CallDurationInSeconds from task limit 1 ];
system.debug(allTasks);
allTasks.CallDurationInSeconds=8;
update allTasks;
double d=double.valueof(allTasks.CallDurationInSeconds); 
system.debug(d);

So go to your code, Have a look on which line the exception appears and check for the variable type where you are assigning the double value of CallDurationInSeconds fields.

Hope it helps you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.