Issue when using JSENCODE











up vote
1
down vote

favorite












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?










share|improve this question


























    up vote
    1
    down vote

    favorite












    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?










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      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?










      share|improve this question













      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?







      javascript error-messages






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 3 at 13:56









      lemdev

      677




      677






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          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)}";





          share|improve this answer





















          • Wowie, thats good catch, I never found any documentation for this
            – Pranay Jaiswal
            Dec 3 at 14:21











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "459"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f241225%2fissue-when-using-jsencode%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          5
          down vote



          accepted










          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)}";





          share|improve this answer





















          • Wowie, thats good catch, I never found any documentation for this
            – Pranay Jaiswal
            Dec 3 at 14:21















          up vote
          5
          down vote



          accepted










          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)}";





          share|improve this answer





















          • Wowie, thats good catch, I never found any documentation for this
            – Pranay Jaiswal
            Dec 3 at 14:21













          up vote
          5
          down vote



          accepted







          up vote
          5
          down vote



          accepted






          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)}";





          share|improve this answer












          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)}";






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 3 at 14:04









          David Reed

          28k61746




          28k61746












          • Wowie, thats good catch, I never found any documentation for this
            – Pranay Jaiswal
            Dec 3 at 14:21


















          • Wowie, thats good catch, I never found any documentation for this
            – Pranay Jaiswal
            Dec 3 at 14:21
















          Wowie, thats good catch, I never found any documentation for this
          – Pranay Jaiswal
          Dec 3 at 14:21




          Wowie, thats good catch, I never found any documentation for this
          – Pranay Jaiswal
          Dec 3 at 14:21


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f241225%2fissue-when-using-jsencode%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Сан-Квентин

          Алькесар

          Josef Freinademetz