Skip to main content

Posts

Showing posts from February, 2017

Using Email Template from Apex and merge it with Apex variable

Requirement : Schedule Email Alert to Opportunity Owner in the early of the month if their Opportunities fulfill some criteria. The email template is like below : Hi Jane , There some opportunities that need to be closed in this month with contract amount more than $50,000.Please update it and reply to this email. Opportunity Owner Opportunity Name Amount Currency Amount Confidence Stage Link Jane Jackson XYZ Canteen USD 60000.00 Upside Create Click here to Opportunity Jane Jackson ABC Devices USD 3000000.00 Upside Create Click here to Opportunity regards, Sales Action Team The highlight mean variable value.To achieve this template we can do html code in apex from scratch which will cost longer time and of course the code will not be so neat.Or we can create Email Template in Setup, and I choose Custom Email Template. In the HTML Body,I generate template as above in HTML. Actually it is very easy, you don't have to code from the scratch.

Compiled formula is too big to execute (6,581 characters). Maximum size is 5,000 characters

Compiled formula is too big to execute (6,581 characters). Maximum size is 5,000 characters Face the issue when compiling this formula : IF (Country_Code__c ='GB' || Country_Code__c ='IE' || Country_Code__c ='ZA' || Country_Code__c ='KE' || Country_Code__c ='MA' || Country_Code__c ='TZ' || Codes__c ='BH' || Country_Code__c ='OM' || Country_Code__c ='AE' || Country_Code__c ='QA' || Country_Code__c ='SA','EMEA_REGION',null ) Requirement if the country field fall into certain code it will be labelled as 'EMEA_REGION' . The formula is very simple but it still throws the exception because Country_Code__c is the formula field itself and it depend on how many times it being called.In this case,Country_Code__c is being called 11 so these will be pulled in formula compilation. The issue can be solved by reducing the calling; IF( CONTAINS("GB:IE:ZA:KE:MA:TZ:BH:OM:AE:QA:SA"