1

I have a piece of Javascript in a Visualforce page. I would like to change the Status of a Case when a button is clicked invoking my Javascript function. I can't figure out the proper syntax for using a custom label from SFDC. Does anyone know how to accomplish this?

Javascript:

<script type="text/javaScript">
     sforce.connection.sessionId = "{!GETSESSIONID()}";
        function Escalate(){
           var confirmMsg = confirm("Are you sure you want to escalate this case to the Client?");
                var c = new sforce.SObject("Case");
                  if(confirmMsg == true){
                     c.id = "{!Case.Id}";
                     c.Escalate_to_Client__c = true;
                     c.Status = "{!$Label.Case_Status7__c}";
                  sforce.connection.update([c]);  
                  }
        }
</script>
3
  • 2
    are you sure that the custom label name ends with "__c "? Looks more like a custom field name. – Guy Clairbois Jun 28 '16 at 19:51
  • can you try c.Status = '{!JSENCODE($Label.Case_Status7__c)}'; – Anurag Jun 28 '16 at 19:54
  • @Guy -- That was it. Wow, was that dumb on my part. Thanks!! – J. Neilan Jun 28 '16 at 20:56
1

*adding my remark as an answer so the question can be closed by you and won't appear as 'unanswered' in the site statistics

Are you sure that the custom label name ends with "__c "? Looks more like a custom field name. Try this:

c.Status = "{!$Label.Case_Status7}";

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.