title: How do I declare then use a variable within a CDATA block?
body: <p>I have an XSL/XML/JS file. It was written by someone who is not working here any more, and I normally only deal with SQL, so Im at a loss as to how to achieve what I need to do</p>
  <p>Im trying to add some variables into the file within the existing CDATA block. I then use the variables within a function. However, I have tried the below and variations of this, but keep getting a syntax error within the application (Dynamics AX). Am I doing something obviously wrong here, with either how I am declaring the variables or how I am using them? These are the only changes I have made, and without these changes there are no syntax or any other issues/errors.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
  &lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; 
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; 
  xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot; 
  xmlns:mxm=&quot;http://schemas.microsoft.com/dynamics/2008/01/documents/MxmServInterfaceOutboundAif&quot; 
  xmlns:data=&quot;http://www.example.com/data&quot; exclude-result-prefixes=&quot;xs xsi xsl&quot;&gt;
    &lt;xsl:output method=&quot;text&quot; encoding=&quot;UTF-8&quot; indent=&quot;no&quot; /&gt;   
      &lt;msxsl:script language=&quot;JScript&quot; implements-prefix=&quot;data&quot;&gt;    
          &lt;![CDATA[      
        
        //Minor Repairs email address  
        var MinorsEmail = xxx@domain.com
        //Service Dept email address
        var ServiceEmail = yyy@domain.com
        //Major Repairs email address  
        var MajorsEmail = zzz@domain.com
  
  //Select appropriate email to use
  function EmailFrom(fault)
        {
          var type = fault.substr(0,2);
          if (type == &quot;MI&quot;)
            {
            var ret = MinorsEmail;
            }
          else 
            {
            var ret = concat(ServiceEmail, &quot;; &quot;,MajorsEmail);
            }
          return ret; 
        }
  </code></pre>
  <p>Edit: Adding quotes around the variable values has solved part of the problem. The problem now is that the CONCAT does not function as intended. I get the following error now:</p>
  <pre><code>Variable concat has not been declared
  </code></pre>