Creating a user exit in JavaScript or C# script

  1. Using any scripting editor tool, copy the source code template for the particular language.
  2. Create your own implementation of the Execute method.
  3. Specify a file name for your script in this format:

    <script filename>.<script engine>.uxt

    where:
    • script filename is any name that identifies your user exit
    • script engine is the script you are using: jvs for JavaScript
  4. Compress the file.
    These are sample scripts for each language:
    • JavaScript
      var Id, Name, Description, Args
      
      Id = "9d43780a-2eb8-425d-a1c9-8dc189758878";                   //Unique Id for the Script, use GUID
      Name = "UserExit using JavaScript scripting";			             //Display Name for this User Exit Script		 
      Description = "This is a UserExit using JavaScript scripting"; //Description for the Script
      Args = []; //This will hold the parameters
      
      //This Execute() method is called every time you run a UserExit, do not remove.
      function Execute() {
      
          //Retrieve and assign a parameter to a variable.
          var htsCode = Args["Style_HTSCode"];
          var taxCost;
      
          if (htsCode == '6105.10.00001') {
              taxCost = 0.07;
          }
          else if (htsCode == '6105.10.0010') {
              taxCost = 0.197;
          }
          else if (htsCode == '6105.10.00') {
              taxCost = 0.20;
          }
          else {
              taxCost = 0.10;
          }
          //return the value.
          return taxCost;
      }
    • C# script
      //Unique Id for the Script, use GUID
      var Id = "9d43880a-2eb8-445d-a1c9-8dc189758882";
      //Display Name for this User Exit Script
      var Name = "UserExit using C# Script";
      //Description for the Script
      var Description = "This is a UserExit using C# Script";
      //Expect this value is passed from script
      //var Args = new Dictionary<string, object>();
      
      //Retrieve and assign a parameter to a variable.
      var htsCode = Args.ContainsKey("Style_HTSCode")?Args["Style_HTSCode"].ToString():string.Empty;
      	
      var taxCost=0.0;
      	
      if (htsCode == "6105.10.00001") {
          taxCost = 0.07;
      }
      else if (htsCode == "6105.10.0010") {
          taxCost = 0.50;
      }
      else if (htsCode == "6105.10.00") {
          taxCost = 0.20;
      }
      else {
          taxCost = 0.10;
      }
      
      //return the value.
      return taxCost;