Preview link :  %%=v(@AmpscriptVariable)=%%           ", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000J8799SAB", "datePublished": "2022-08-29T11:11:18.000Z", "author": { "@type": "Person", "name": "Shashi Prasad", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000FSoCcQAL", "affiliation": { "@type": "Organization", "name": "HCL Tech" } } } ] } }
Skip to main content

Hi

 

How to pass a variable from client JavaScript to server JavaScript [in SSJS] and Vice versa?  

 

Thanks,

Naga.

4 answers
  1. Aug 29, 2022, 11:11 AM

    try this :

    <script runat="server">       Platform.Load("core", "1.1");   function GetValue(){     var jsVaraible=Variable.GetValue("@AmpscriptVariable")     } </script> <script>   function setValue(){     var jsVaraible='Shashi';     Variable.SetValue("@AmpscriptVariable",jsVaraible)     GetValue();   } </script> <html>   <body>      Preview link :  %%=v(@AmpscriptVariable)=%%     <button onclick="setValue();"> </button>   </body> </html>  

0/9000