Script Dynamic Action

About

Script package action enables the implementation of advanced checks and validations.

Two languages are supported:

  • Pascal Script
  • Python

Pascal Script Example

Var I : Integer;
begin
 I:=1;
 SetVariable('I',I);
 I:=GetVariable('I');
 WriteToLog('Error',I);
 Result:=True;
end;
Result:=True; => Success
Result:=False; => Failure

Python Example

import etltools
etltools.SetVariable('<Time>',15)
s=etltools.GetVariable('<Name>')
etltools.WriteToLog('Done')
Result.Value = 0
Result.Value = 1 => Success
Result.Value = 0 => Failure

Metadata tab

Script Action - Metadata tab
 

  1. The Write Variables option ensures that the “Package Action” logs the variable values into the “Action vars before log file” before the action is executed and logs the updated variable values into the “Action vars after log file” after the action completes.
  2. This option is typically used for debugging and is not recommended in a production environment.
  3. It can be globally disabled through the options dialog .

Parameters tab

Script Action - Parameters tab

Selecting Script

Script Action - Editing Script Parameter

Script tab

Script Action - Script tab

Script Action - UseEmbeddedSQL Parameter

Variables tab

The Variables tab defines the variables to be updated during the action’s execution.

Script Action - Variables tab

Execution log tab

The Execution log tab is populated after the action is executed. Double click on the row to view the log.

Script Action - Execution log tab

Script example: Working with Crystal reports

var
CrystalRFileName: String;
ExportFileName: String;
CrystalRApplication, CrystalReport: Variant;

begin
CrystalRFileName := GetVariable('<CrystalRFileName>') ;
ExportFileName := GetVariable('<ExportFileName>') ;
CrystalRApplication := Null;
CrystalReport := Null;

try
CrystalRApplication := CreateOleObject('CrystalRunTime.Application');
CrystalReport := CreateOleObject('CrystalRunTime.Report');
//Result := CrystalRApplication.GetVersion;

except
CrystalRApplication := Null;
CrystalReport := Null;
end;

If VarIsNull(CrystalRApplication) = False then
begin
try
//Result := CrystalRApplication.GetVersion;

    try
    CrystalReport := CrystalRApplication.OpenReport(CrystalRFileName);
    CrystalReport.ExportOptions.FormatType := 31;
    CrystalReport.ExportOptions.DiskFileName := ExportFileName;
    CrystalReport.ExportOptions.DestinationType := 1;
    CrystalReport.ExportOptions.PDFExportAllPages := True;
    CrystalReport.Export(False);
     Result := CrystalReport.ApplicationName;
    except
    CrystalReport := Null;
    end;
    finally

       //Result := CrystalRApplication.CanClose;
       Result := true;
     end;

end;
end;

Python example: Killing Microsoft Excel or any other app

import etltools, subprocess
def main():
    try:
        # Check if Excel is running
        if subprocess.call('tasklist /FI "IMAGENAME eq excel.exe" | find /I /C "excel.exe"', shell=True) == 0:
            # Excel is running, attempt to kill it
            subprocess.run(['taskkill', '/F', '/IM', 'excel.exe'], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
            etltools.SetVariable('excel_status', 'Excel was running and has been terminated.')
        else:
            # Excel is not running
            etltools.SetVariable('excel_status', 'Excel was not running. No action taken.')

        Result.Value = 1  # Success in both cases
    except subprocess.CalledProcessError as e:
        etltools.SetVariable('excel_status', f"Failed to kill Excel: {str(e)}")
        Result.Value = 0  # Failure
    except Exception as e:
        etltools.SetVariable('excel_status', f"An unexpected error occurred: {str(e)}")
        Result.Value = 0  # Failure

main()

For more technologies supported by our ETL Software see Advanced ETL Processor Versions

Confused? Ask question on our ETL Forum

Posted on September 17, 2025 • 3 min read • 465 words
www.etl-tools.com About Support Pricing Cookies Policy Term Of Use Privacy Policy License