Introduction

 Variable is a container that holds a value and can be called in the iXPath Scenario. The importance of

variables is to make flexibility in using some values without referring to their origins. 

There are 2 types of  variables:  

  • System variables 
  • Local variables 

System variables

System variables define some default values in the system, and they can be called by users several times. 

Here is the list of system variables : 

  1. At the declaration of the scenario:
    • iXSession: it returns the ID of the current session.
    • iXSessionPath: gets the Path of the session folder. 
    • env: name of the environment.
    • inputFile: this variable collect all input files in one list.
  2. For a mail listener : 
    • iXFrom: refers to the sender of the mail that we are listening on.
    • iXSubject: refers to the Subject of the mail that we are listening on.
  3. For an AS2 listener 
    • iXFrom: return the value of the source of the AS2 that we are listening on.
  4. All connectors declare a system variable of type BpmnFile, the connector variable uses a bunch of functions to handle the list of BpmnFiles that will be detailed in the table below  :
    • FunctionDescriptionUse
      Get( x ) Get a file with index number "x" from the BpmnFile list, the indexes begin from 0 as the first element, and so on.

      if we have an XmlToXml connector named "XmlToXml1" we can get the second BpmnFile as :

      ${XmlToXml1.get(1)}

      NB: we will make examples on the same connector "XmlToXml1".

      getTrkValues()Return the Tracking values from a BpmnFile.Eg : ${XmlToXml1.get(0).getTrkValues()} returns the tracking values of the first BpmnFile.
      path()Return the absolute path of the BpmnFile.Eg : ${XmlToXml.get(3).path()} returns the path of the fourth BpmnFile 
      fileName()Return the name of the BpmnFile. Eg : ${XmlToXml1.get(2).fileName()} retrieves the name of the third BpmnFile.
      extension()Returns the extension of the BpmnFile.

      Eg : if we want to get the extension of the first BpmnFile, we will proceed as below :

               ${XmlToXml1.get(0).extension()}

      fullName()Returns the file name + its extension  Eg : ${XmlToXml1.get(0).fullName()} returns the full name of the BpmnFile.
      size()Returns the size of the BpmnFile in megabit.

      Eg : ${XmlToXml1.get(0).size()} returns the size of the first BpmnFile.

      type()Returns the type of the BpmnFile

      Eg : To get the type of the second BpmnFile ,

      ${XmlToXml1.get(1).type()}

  5. Variables used to charge the connectors properties in the xsl file without charging them in the scenario manually. Those variables helps reduce time consuming and avoid reputation in the scenario elements:
    • For the SendFTP et SendSFTP, there are 3 variables:
      • i​​XTo: used to charge the property Destination of the connector in the XSL file.
      • iXServerConfig: used to charge the property Server Config of the connector in the XSL file.
      • iXDirectory: used to charge the property Folder of the connector in the XSL file.
      • SendFtp.png
    • For the CallScenario Connector, there are 3 variables:
      • iXScenario: used to charge the property Scenario of the connector in the XSL file.
      • iXSwitchEnv: is a boolean variable used to charge the checkbox property switch environnement of the connector in the XSL file.
      • iXEnv: used especially when the developper wants to switch the environment and use another scenario in another environment. It is a variable that precise the name of the new environment
      • 1649942613906-103.png

When you change the environment, make sure to verify that the variable iXSwitchEnv has the value true.

Local variables

Local variable is a type of variable that can be newly created and used for a certain need.

So as to create a local variable "newVar" with a value equals to "var number 1", we should write this piece of XSL code : 

<xsl:value-of select=" ixf:SetVar('newVar', 'var Number 1','false')"></xsl:value-of>

The call of this new variable in the scenario is similar to previous system variables:  ${newVar}.

To get 'newVar' inside an XSL file : 

<xsl:value-of select="ixf:getVar('newVar')"></xsl:value-of>

How to call the variables? :

To call a variable inside a connector, we should put it inside ${}. Eg: for a variable named ‘Var’, it can be called as ${Var}.

For the condition in the connector's property, to check if the variable verify the condition, we can use " VarName== 'Value' " or " VarName!='Value' ".

To call a variable in an xsl file, we should use the local variables SetVar ou GetVar.

Examples

  • 1st Example:

     

We set a simple example of a scenario to illustrate how to use variables.

We want to receive a file by a FileListener and send it by mail that contains a message body.

here is the scenario: 

                     2021-04-27_21h31_55.png

The configuration of the "SendMail" is :

               2021-04-27_21h32_07.png

As shown in the mail body, we called 3 variables which are :

  •   Env: the current environment
  •   iXSession : ID session
  •   path : the path of BpmnFile in FileListener1.
  • 2nd Example

     

This is an example to charge the call scenario variables:

1649943564529-130.png

As shown in the mail body, we called 3 variables which are :

  • iXEnv: the Environment when the new scenario exists
  • iXScenario: ='error_sc_out_trk_and_statut'. It means that the current scenariowhere the connector CallScenario will be changed to "error_sc_out_trk_and_statut'"
  • iXSwitchEnv: ='true'. It means that the current env will be switched to "Danone"

String Class

in java language, The String class represents character strings. It contains a lot of functions to handle String object.

you can discover all these functions on the following URL : 

https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#method.summary 

Eg: to check if a variable "myVar" is empty or not, we refer to the isEmpty() method as ${myVar.isEmpty()}, if so then it returns true, if not it will return false.

 

Tags:
    
This wiki is hosted and managed by iXPath
Powered by XWiki 13.3 debian