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
Kevin WinnKevin Winn 

Illegal Integer but only after a threshold

Hi All,

We are deploying a tiered schedule for pricing related to products based on a firms assets under management.  The tiers have breakpoints based on these aum fields (currency).

In apex I have a method for building tier schedules, which works fine until I hit the $3B entry breakpoint.  When I run the method at this breakpoint, I get a message in the developer console about an 'Illegal Integer'. 

The Apex Method that I have accepts the following parameters and then processes the new tier schedules:

public static List<rbTier__c> createTiers(Id productFamilyId, Integer batchSize, Decimal beginningAUM, decimal aumIncrement, Decimal beginningBasePrice, Decimal basePriceIncrement)
	{
		List<rbTier__c> tierList = new List<rbTier__c>();
		List<rbTierFamily__c> familyList = [Select Id, Name, RB_Product__c From rbTierFamily__c WHere Id = :productFamilyId];
		List<rbTier__c> existingTiers = getTiersForFamilies(familyList);
		Integer sequence = 0;
		INteger plusOne = 1;
		Integer minusOne = -1;
		Decimal aumFloor = beginningAUM;
		Decimal aumCeiling = aumFloor + aumIncrement + minusOne;
		if(existingTiers.size() > 0)
		{
			sequence = existingTiers.size() + plusOne;
		}
		else
		{
			sequence = 1;
		}
		for(Integer i = 0;i < batchSize; i++)
		{
			if(sequence == 1)
			{
				rbTier__c t = new rbTier__c();
				t.AUM_Floor__c = aumFloor;
				t.AUM_Ceiling__c = beginningAUM + aumIncrement;
				t.Sequence__c = sequence + (1 * i);
				t.Name = 'Tier '+ String.valueOf(sequence + (1 * i));
				t.Base_Amount__c = beginningBasePrice + (basePriceIncrement * i);
				t.RB_Tier_Family__c = productFamilyId;
				tierList.add(t);
				aumFloor = aumCeiling + plusOne;
				aumCeiling = aumFloor + aumIncrement + minusOne;
			}
			else
			{
				System.debug('aum floor entering loop is '+aumFloor+ ' and aum ceiling entering is '+ aumCeiling);
				rbTier__c t = new rbTier__c();
				t.AUM_Floor__c = aumFloor;
				t.AUM_Ceiling__c = aumCeiling;
				t.Sequence__c = sequence + (1 * i);
				t.Name = 'Tier '+ String.valueOf(sequence + (1 * i));
				t.Base_Amount__c = beginningBasePrice + (basePriceIncrement * i);
				t.RB_Tier_Family__c = productFamilyId;
				tierList.add(t);
				aumFloor = aumCeiling + plusOne;
				aumCeiling = aumFloor + aumIncrement + minusOne;
				System.debug('aum floor exiting loop is '+aumFloor+ ' and aum ceiling exiting is '+ aumCeiling + ' and AUM increment is '+ aumIncrement);

			}
		}
		if(tierList.size() > 0)
		{
			try 
			{
				RBS_GlobalDMLHandler.insertObjectList(tierList);	
			} 
			catch(Exception ex) 
			{
				System.debug('Problem encountered inserting the tier batch | '+ex.getMessage());
			}
		}
		return tierList;
	}

I ran this in from the developer console in stages as outlined here:
(note the Id is hardcoded only for the purposes of testing)
RBS_TierHelper.createTiers('a184B000000xdd9QAA', 1, 0, 99999999, 10000, 0);
RBS_TierHelper.createTiers('a184B000000xdd9QAA', 8, 100000000, 50000000, 11250, 1250);
RBS_TierHelper.createTiers('a184B000000xdd9QAA', 5, 500000000, 100000000, 22500, 2500);
RBS_TierHelper.createTiers('a184B000000xdd9QAA', 8, 1000000000, 250000000, 35000, 2500);
RBS_TierHelper.createTiers('a184B000000xdd9QAA', 4, 3000000000, 500000000, 55000, 5000);

The outputs for the first four traunches result in what I would expect:
User-added image

When I run the last call to insert tier schedules with a beginning AUM of $3B, i get 'Line 7, Column: 53 Illegal Integer'

Does anyone know what is going wrong here?

Thanks in advance for any insight you can provide!

Best Answer chosen by Kevin Winn
Kevin WinnKevin Winn
I posted this same question to https://salesforce.stackexchange.com/questions and received the direction to solve this problem.  The article is found at https://salesforce.stackexchange.com/questions/250736/illegal-integer-but-only-after-threshold

All Answers

Kevin WinnKevin Winn
as a side note, the final tier I am trying to get to would have a beginning AUM (aumFloor) of $10,000,000,000 and the aumCeiling value would be the max possible value for the currency field ($999,999,999,999,999).
Kevin WinnKevin Winn
I posted this same question to https://salesforce.stackexchange.com/questions and received the direction to solve this problem.  The article is found at https://salesforce.stackexchange.com/questions/250736/illegal-integer-but-only-after-threshold
This was selected as the best answer