Page 1 of 1

Retrieve System Name

Posted: Wed Jun 03, 2009 9:25 am
by kdanforth
Is there a way to retrieve the system name in Go Anywhere (similar to RTVNETA)? I want to be able to condition some tasks based on the system on which the project is running.

Re: Retrieve System Name

Posted: Wed Jun 03, 2009 11:21 am
by Support_Ron
At this time there is no variables available in GoAnywhere to retrieve this information.
You could however add a program call to retrieve this information for now

Thanks
Ron

Re: Retrieve System Name

Posted: Fri Jun 05, 2009 9:28 am
by Support_Sai
It is possible in GoAnywhere to define and import a set of variables that could act as global/system variables. You can import parts of a project from external XML files. This works much like the COPYBOOK feature in System i programs.

Follow the instructions below to set this up:

Create a simple XML file with all global variables that you would like to import into all/most of your projects. Place the file in a folder of your choice (preferably in the ~goanywhere/userdata/imports). For this example, let us name the file as Global Variables.xml. Below are the contents of our Global Variables.xml file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<globalVariables>
	<variable name="global.system.name" value="S10BD458" />
	<variable name="global.emails" value="[email protected], [email protected]" />
</globalVariables>
Basically we have two variables in this file. One that indicates the system name, and the other contains the list of email addresses to receive error notifications.

Now, we can import this file into any project and the two variables we have defined in the file will be available to the project at execution time. Below is a sample project that imports the above file and conditionally runs a task based on the system name:
Code: Select all
<project name="Import Variables Demo" mainModule="Main" version="1.0">

	<module name="Main">

		<print if="global.system.name eq &apos;S10BD458&apos;">
			<![CDATA[Hello World!]]>
		</print>

	</module>

	<import file="/linoma/goanywhere/userdata/imports/Global Variables.xml" />
</project>
As you might have noticed, we imported the Global Variables.xml file into the project. To do this, right click on the Project node in the Project Designer and select Import an XML File from the context menu. During the execution of the project, the Project Compiler copies the contents of the Global Variables.xml into the project (excluding the root element, in our case <globalVariables>). The expanded project is then executed.

Now, make a copy of the Global Variables.xml file and move it to your second system. Adjust the variable values as needed.

Not only you can import variables, but you can import other project components such as Modules and Tasks. So, it is possible to have a common E-Mail task that sends out error notifications in a separate file and import that task into several projects.

Note:
When working in the Project Designer, variables from the imported file are not displayed in the Variable Selection Drop-down. The imported file is loaded only at project's execution time. Any subsequent changes made to the imported file will be automatically reflected when the projects are executed the next time.

Re: Retrieve System Name

Posted: Mon Jun 22, 2009 3:14 pm
by Support_Steve
You can now perform conditional logic on the system.instanceName variable in GoAnywhere version 2.3.0. The instance name can be set in the Global Settings and is useful when you have multiple instances of GoAnywhere running. You can now use that variable in your Execute Only If logic on each task/module to control processing.

In the example below I have a Project that sends emails. I set the Execute Only If attribute to compare it to the system.instanceName. In the example the email is only sent if it's running on the Production instance of GoAnywhere.
Code: Select all
<project name="Production Email" mainModule="Main" version="1.0">
	<description>Send a notification email</description>
	<module name="Main">
		<sendEmail if="system.instanceName eq &apos;Production&apos;" resourceId="SMTP" toList="[email protected]">
			<from address="[email protected]" />
			<subject>
				<![CDATA[This job has completed successfully. ]]>
			</subject>
			<message>
				<![CDATA[Jog number = ${system.job.id}]]>
			</message>
		</sendEmail>
	</module>
</project>