I tried this code in Apex, but unfortunately it gives this error. EXCEPTION_THROWN [74]|System.CalloutException: Function HTMLENCODE may not be used in this type of formula.