Have you ever wondered how to pass environment variables to xMII transactions ?
You are trying to create a BLS transaction and you need to create a text file, maybe a log, with the name of the user logged in and the datetime but you have absolutely no clue as to how to pass the xMII username at runtime ?
Fear not, as the solution is not as difficult as it seems !
To get started we would have to do a small configuration in the Xacuteconnector in the Data Servers under the Data Services tab.
On the Data Servers page select the Xacuteconnector and on the properties tab check Autobind if not already checked and click on save.
Now open the BLS editor by going to Business Logic Services -> Logic Editor. We’ll be creating a new transaction now. Now add a Transaction Parameter by going to *Transaction -> Properties * and click on Add. Call the parameter IllumLoginName, choose the Data Type as String and click OK. Now add another Transaction Parameter called UserName, choose the Data Type as String, check the Output Parameter? checkbox and click OK.
We’ll go on with the BLS, but first let me explain what we just did. If Autobind is checked for the XacuteConnector, in BLS transaction, xMII searches for Transaction variables having a name which is same as that of any environment variable and if it finds one, substitutes the value of the Transaction variable with that of the environment variable at runtime.
Note that this binding takes place only at runtime so executing the Transaction and checking the step trace will not return the value of this parameter.
Here IllumLoginName is the name of the environment variable which holds the value of the Login Name of the xMII user.
Now, in the Logic Editor add a Assignment Block from Logic -> Assignment by dragging and dropping it on the sequence. Right click on the Assignment Block and select Links.
On the Link Editor expand the Transaction Node on the both sides in the Incoming tab. Now drag and drop the IllumLogiName field on the left side to the Username field on the right side.
Now in the Expession Editor change the expression from : + Transaction.IllumLoginName+ to + “Hello ” & Transaction.IllumLoginName & ” !!!”+ and click on Update.
Now save the Transaction as QRY_Autobind. It’s time now to create a Xacute Query to test our creation. Go to Data Services and click on the Query Templates link. When the Query Template Editor pops up click on New and select XacuteQuery from the list.
In the Servers tab select XacuteConnector and in the Modes tab select Query.
Click on the Transaction tab, from the Folders tab select the folder you saved your BLS transaction to, select your transaction in the Transactions tab, which in our case will be Xacute_Autobind and select the Output Parameter UserName in the Outputs tab.
Save the Query as QRY_Autobind, fire up your browser and run the query using the Illuminator service as :
The output of the Query should be “Hello <username> !!!”.
Output when tested from local machine on which xMII is installed :
Output when tested from another machine in the network with my user :
Phew ! Done at last ! Was not that difficult was it ?
Since quite a few people have been asking for a List of Environment Variables here’s a bit of info about them as well.
A list of the Environment Variables set can be found by using the following URL :
And any User Attributes we set for a particular user is also available as an environment variable.
This can be accessed via “Security Services -> Security Manager -> User Management -> Users” link. Choose any Attribute, click on add and then set a value to the attribute. You can also create User Attributes by using the “User Attributes” menu under “User Management”.