1

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?

1 Answer 1

2

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .