I have the following issue:

var accountScheduler = "{!JSENCODE(Account.Number_Of_Due_Days__c)}";

Upon initializing the accountScheduler variable I receive the following error:

Error: Incorrect argument type for function 'JSENCODE()'.

Could you please advise what could be the reason and how to avoid such error?


As I can see Number_Of_Due_Days__c is a Number where as JSENCODE accepts a text/String. Thus you have to convert the Number into Text.

var accountScheduler = "{!JSENCODE(Account.Number_Of_Due_Days__c.toString())}";

Src: https://help.salesforce.com/articleView?id=customize_functions_i_z.htm&type=5

  • 1
    {!JSENCODE(TEXT(Account.Number_Of_Due_Days__c))} you mean. – sfdcfox Dec 28 '18 at 15:11
  • 2
    Is it even required to jsencode a number field? – Raul Dec 28 '18 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.