Creating a user exit in JavaScript or VBScript

  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: vbs for VBScript and jvs for JavaScript
  4. Access the Extensions folder, located at C:\Users\<username>\AppData\Roaming\Infor\Extensions, and copy your script file in the folder.
    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;
      }
    • VBScript
      Dim Id, Name, Description, Args
      
      Id = "206eeb59-d83b-4459-aec1-3e7b6bd78fbe"                 '* Unique Id for the Script, use GUID
      Name = "UserExit using VBScript scripting"                  '* Display Name for this Plugin Script
      Description = "This is a sample User Exit using VBScript"   '* Description for the Script
      
      '* This will hold the parameters
      Set Args = CreateObject("Scripting.Dictionary")
      
      '* This Execute() method is called every time you run a UserExit, do not remove.
      Function Execute() 
        Dim categoryCode
        categoryCode = Args.Item("Style_CategoryCode")
        
      	If categoryCode = "SH" Then
      		Execute=FormatNumber(100.25)
      	ElseIf categoryCode = "DR" Then
      		Execute=FormatNumber(215.123456, 6)
      	ElseIf categoryCode = "PT" Then
      		Execute=FormatNumber(890.89, 3)
      	Else
          Execute=FormatNumber(950.564351)
      	End If
      	
      	'* Always set the Args variable to Nothing after using it.
      	Set Args = Nothing
      End Function