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
Santiago GMZSantiago GMZ 

Create a trigger to calculate values

Hi 

I have one formula field that has reached teh 5k character limit and still need it to do some extra calculations. 

I reached out Salesforce Support for gudance, but only received a create an apex trigger to run teh calculation, also that they donot help to do any custom coding. 

I know my way with Flows, formulas and validation, but in APEX I consider myself a NOOB . Can somebody if you can help me. 

The thing is that the prevoiousAdmin created a Duplciate field

ACV & ACV (WPS) Mainly both fields calculate the same value but using diferent parameters depending of teh Opportunity record type. 

They are set up in the following Matter:
 
Custom Field ACV__c type currency 

IF ( RecordType.Name  <> "WHP - Opportunity",  ACV_WPS__c , 
IF(
(Contract_term_months__c > 0) && (Contract_term_months__c < 12),
Final_MCV_number__c *Contract_term_months__c ,
Final_MCV_number__c *12)
)
ACV (WPS)
 
IF(
OR(
RecordType.DeveloperName='NCL_Logbox',RecordType.DeveloperName='Opportunite_Logbox_verrouillee',RecordType.DeveloperName='NCL_Logbox_Extension')
&&
OR(
ISPICKVAL(Type,'NCL - Nouveau Client'),
ISPICKVAL(Type,'E - Extension'),
ISPICKVAL(Type,'L - Nouvelle Ligne de Produits')),
IF(
NOT(ISNULL(Taux_logbox__c)),VA_prevu__c*Taux_logbox__c,VA_prevu__c*Taux_logbox_CG__c)+VA_prevu__c*Taux_logbox_CG__c
,null)


I tried to merge Both Fields inti a single one (ACV) but received the alert of maxium characters limit. 

Obuusly the expression "IF ( RecordType.Name <> "WHP - Opportunity", ACV_WPS__c , " is not longuer needed.

Any ideas? suggestions, example coding ? 

Thanks a lot!!!

Santiago

MedhyaMedhya
Hi Santiago, 

Per my knowledge SF includes the characters of other formula fields too if you use them within the formula. ( i.e if you use a formula Age__c > 10) and Age__c itself has 5k characters, it will end up giving you an error. 

On workaround to number of characters is to use Process builder to update your (Text/Number or whatever return type of formula you have ) on the object once your record is edited. The formula character limit doesnt cause a problem in process builder as such. 

I suggest you combine your formulas in a Process builder and update your result field. 

Let me know if it helps you. 

Regards
Medhya