Thursday 9 August 2018

How to use custom Lebel in javascript file ?

We all know how custom labels are useful, we can use in apex/visual force/workflow formula/validation rule etc. This post is all about hot to use in java script file which is been uploaded in static resource.

In the page just add these two lines of code, which will make js file understand the custom label.

 <script>
      window.$Label = window.$Label || {};
$Label.CUSUTOMLABELNAME = '{!JSENCODE($Label.CUSUTOMLABELNAME )}';

</script>

In the java script file use like below
alert($Label.CUSUTOMLABELNAME );


No comments: