Loading
Feature Disruption - Service Cloud VoiceRead More
Feature degradation | Gmail Email delivery failureRead More

Convert the currency value to an integer using Apex

Publish Date: Oct 13, 2022
Description

This article specifies one way to convert the currency value to integer.

Use case: Convert Currency data type to Integer

Resolution

The method valueOf can be used to convert the currency to integer. 

Sample Code:
Here the AnnualRevenue column in Account object is of type currency.  This value is converted to integer and added to list quarterBonus. 

Account acc1 = [select AnnualRevenue from account where AnnualRevenue != null limit 1];

System.debug(‘Annual Revenue: ' + acc1.AnnualRevenue);

list<integer> quarterBonus = new list<integer>(1);
quarterBonus.add(0,integer.valueOf(acc1.AnnualRevenue));

system.debug('Quarter Bonus: ' + quarterBonus[0] );

Please note that this is just a sample code and may not satisfy your complete business needs.

Dev Doc: Integer Class 

Knowledge Article Number

000387949

 
Loading
Salesforce Help | Article