1

When I use the JSENCODE I have the following issue:

var accRegNumber = "{!Account.Registration_Number__c}";
var accName = "{!Account.Name}";
var accType = "{!Account.Custom_Filed_Type__c}";
var accRate = "{!Account.Custom_Filed_Rate__c}";
var accId = "{!Account.Id}";

accRegNumber = {!JSENCODE(accRegNumber)};
accName = {!JSENCODE(accName)};
accType = {!JSENCODE(accType)};
accRate = {!JSENCODE(accRate)};
accId = {!JSENCODE(accId)};

Error: Field accRegNumber does not exist. Check spelling.

Could you please advise why adding {!JSENCODE(accRegNumber)}; to accRegNumber variable is giving an error message?

0

1 Answer 1

6

accRegNumber is a JavaScript variable. The Salesforce formula expression {!JSENCODE(accRegNumber)} is processed by the server long before the content reaches the JavaScript parser, and the server doesn't know anything about the JavaScript variables you're creating.

You need to write the formula as part of the original assignment:

var accRegNumber = "{!JSENCODE(Account.Registration_Number__c)}";
1
  • Wowie, thats good catch, I never found any documentation for this Commented Dec 3, 2018 at 14:21

You must log in to answer this question.

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