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
Zach AckermanZach Ackerman 

Infinity Symbol

I have a fields I populate with apex code that are percentages/currency. They are populated based on the type of plan it is. In some cases the value to be associated with the fields are infinity. Is there anyway I can use the inifity symbol in the curreny/percentage field? I attempted to build this into the code and it said "Error: Compile Error: Illegal assignment from String to Decimal at line 243 column 9". Any help would be greatly appreciated. 
SandhyaSandhya (Salesforce Developers) 
Hi Zach Ackerman,

if assigning a String value to a Decimal variable then the above Illegal assignment error  occurs.

Apex is strongly typed so try to do the below changes in coding. Decimal.valueOf()

For example,
c.Order_Amount__c = Decimal.valueOf(OrderAmount_Value);

Hope this helps you!


Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
 
Thanks and Regards
Sandhya

 
Zach AckermanZach Ackerman
How would I use the above with the following. 

        IF(Plan.Armada_Plan_Package_Name__c == '2000' &&
        Plan.Sum_of_Benefits__c ==0)
        {
        Plan.Annual_Family_Maximum__c=∞;
        }
SandhyaSandhya (Salesforce Developers) 
Hi,

Not sure if it works here but you can try something like this.
string s='∞'
        Plan.Annual_Family_Maximum__c=Decimal.valueOf(s);

Hope this helps you!

Thanks and Regards
Sandhya

 
Zach AckermanZach Ackerman
It let's me save the code, but when i try to use the code I get a failure message. 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger PlanPackageNames caused an unexpected exception, contact your administrator: PlanPackageNames: execution of BeforeInsert caused by: System.TypeException: Invalid decimal: ∞: Trigger.PlanPackageNames: line 276, column 1