Skip to main content
Skip table of contents

ExecuteFunction: run a previously declared function

The ExecuteFunction tag allows to execute a function that was previously declared in the script.

Detailed Description

Runs a function, with all its local variables and lists reset (as if they had never existed).

Can use the same Echo and OnError parameters as its declaration. If set, they override the default values set in the declaration. If unset, these default values apply.

Tag Attributes


Value Description


Any unreserved name valid in XML. Reserved names are listed on: Variables



True: turn echo on

False: turn echo off

Default (value not set): current script setting


Local: bypass script OnError setting and use default OnError settings; <OnError …/> tags inside the function remain local and do not alter the main script

Global: use main script current OnError setting

Default: Global

NB: if Global and an <OnError …/> action tag appears inside the function, it sets the main script error management.

NB: sapio365 job presets parse the function for each call, not at declaration time.

Example Scripts

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<ytriaAutomation Console="True">

<list name="ListGlobal" Action="setVar" Dname="L1"/>
<list name="ListGlobal" Action="setVar" Dname="L2"/>
<list name="ListGlobal" Action="setVar" Dname="L3"/>

<SetVar GlobalVar="Top level var"/>
<SetVar FirstFunction="F1"/>

Declare function Local OnError and no trace:
<function name="{%FirstFunction%}" OnError="Local" echo="false">

    local error mgt:
	<OnError continue="true" MsgBox="Function error!"/>
	<echo value="+++++++++ Let us run {%FirstFunction%}"/>
	<echo value="global var: {%GlobalVar%}"/>
	<echo value ="Size of ListGlobal in {%FirstFunction%} = {%lSize%}"/>
	<list name="ListLocal" Action="setVar" Dname="O1"/>
	<list name="ListLocal" Action="setVar" Dname="O2"/>
	<SetVarListSize localSize='ListLocal'/>
	<echo value ="Size of ListLocal in {%FirstFunction%} = {%localSize%}"/>
	<echo value="Before set local var: {%LocalVar%}"/>
	<SetVar LocalVar="LocalVar"/>
	<echo value="After set local var: {%LocalVar%}"/>
	<list name="ListGlobal" Action="setVar" Dname="L4 added in {%FirstFunction%}"/>
	<SetVar GlobalVar="This text was set in {%FirstFunction%}"/>
	<echo value="After break, should not display"/>

<SetVarListSize lSize='ListGlobal'/>
<echo value ="MAIN size of ListGlobal {%lSize%}"/>
<echo value ="MAIN GlobalVar = '{%GlobalVar%}'"/>

<echo value="About to run function {%FirstFunction%} with default echo off/local OnError"/>
run function:
<executeFunction name="{%FirstFunction%}"/>

<SetVarListSize lSize='ListGlobal'/>
<echo value ="MAIN size of ListGlobal {%lSize%}"/>
<echo value ="MAIN GlobalVar in Main = '{%GlobalVar%}'"/>

Check if variables set in function are visible:
<echo value="MAIN ********* local var: '{%LocalVar%}' * should be empty"/>
<echo value="MAIN ********* Size of ListLocal: '{%localSize%}' * should be empty"/>
NB: these variables are now global, next function call will not erase them


<echo value="After error in main, should not display"/>

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.