Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This class provides methods that allow for importing data from external partiessources.

SimpleImport()


Instantiates Use this constructor to instantiate a new SimpleImport class object.

Example:

Code Block
languagejs
themeEclipse
titleSimpleImport
const imp = new SimpleImport();

getErrorMessage()


This method returns the current Use this method to get an error message.

Return:

TypeDescription
String
The
This method returns the error message text

Example:

Code Block
languagejs
themeEclipse
titlegetErrorMessage()
linenumberstrue
const imp = new SimpleImport();
if (imp.transform(current)) {
    ss.addInfoMessage('Import succeeded');
} else {
    ss.addErrorMessage(imp.getErrorMessage());
}

import(record, testMode)


Use this method to import records. The method takes a record from the Import Sources (sys_import_source) tables table and imports the entries records from the attachment to the table created via the Import Set Table Name set table name field. As a result, there is a table with temporary records: an import set, from which the system imports the records to the target table.

The record parameter should be a record from the Import Sources (sys_import_source) table.

The testmode parameter is a Boolean parameter. If its value is 'true', the test import is performed and the operation status as '"test' " is displayed.

Parameter(s):

NameTypeMandatoryDefault
Value
value
recordSimpleRecord objectYN
testModeBooleanN
'
false
'

Return:

TypeDescription
BooleanThis method returns
'
true
'
if the import has been completed successfully; otherwise, it returns
'
false
'
.

Example:

Code Block
languagejs
themeEclipse
titleimport()
linenumberstrue
const current = new SimpleRecord('sys_import_source');
current.name='Test Imp JSON'
current.format='JSON'
current.import_set_table_name = 'c_imp_text_json2';
current.import_text = '{"token":"example_Token","user":"zabix_user","title":"Problem: Agent is not available (for 3m)","message":"Problemverity: Average","url":"/tr_events.php","url_title":"ZabbixUrlTitle","priority":"0"}';
current.type = 'Text';
current.insert();
ss.info("RecordImp: " + current.getErrors())
const imp = new SimpleImport();
const result = imp.import(current);
if (result) {
    ss.addInfoMessage("Import successful");
    return;
} else {
    ss.info("Errors Import:  " + imp.getErrorMessage());
    ss.addErrorMessage("Import failed");
}

importTransform(record)


Use this method for the scheduled import runningto initiate a scheduled import.

The record parameter must be the record from the Scheduled Imports (sys_schedule_import) table.

The method gets a record from the Scheduled Imports (sys_schedule_import)table, imports, performs import and transforms in one it at the same time.

Parameter(s):

NameTypeMandatoryDefault
Value
value
recordSimpleRecord objectYN

Return:

TypeDescription
Void

This method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titleimportTransform()
linenumberstrue
const imp = new SimpleImport();
imp.importTransform(current);

testLdapConnection(record)


This Use this method verifies to verify the connection to the LDAP server and alerts . The method contains a message about a successful connection or about an error.

The record parameter parameter must be the filled with the sys_id ID of the LDAP server Server (sys_ldap_server)table record related to this connection.  

Parameter(s):

NameTypeMandatoryDefault
Value
value
record

SimpleRecord

(

object

of the LDAP server (sys_ldap_server) table)

YN

Return:

TypeDescription
ObjectThe method returns an object containing an LDAP server connection status or a connection error message
(in case of connectivity issues)
.

Example:

Code Block
languagejs
themeEclipse
titletestLdapConnection()
linenumberstrue
const imp = new SimpleImport();
const result = imp.testLdapConnection(current);
if (result.flash.type === "success") {
    ss.addInfoMessage(result.flash.message);
    return;
}
if (result.flash.type === "error") {
    ss.addErrorMessage(result.flash.message);
}

testLdapConnections(record)


This Use this method verifies to verify all connections to the LDAP server and alerts . The method contains a message about a successful connection or about an error.

The record parameter parameter must be the filled with the sys_id ID of the LDAP server Server (sys_ldap_server)table record related to this connection. 

Parameter(s):

NameTypeMandatoryDefault
Value
value
record

SimpleRecord

(

object

of the LDAP server (sys_ldap_server) table)

YN

Return:

TypeDescription
ObjectThe method returns an object containing LDAP server connections statuses or connection error messages
(in case of connectivity issues)
.

Example:

Code Block
languagejs
themeEclipse
titletestLdapConnection()
linenumberstrue
const imp = new SimpleImport();
const result = imp.testLdapConnections(current);
if (result.flash.type === "success") {
	ss.addInfoMessage(result.flash.message);
    return;
}
if (result.flash.type === "error") {
	ss.addErrorMessage(result.flash.message);
}

transform(record)


This Use this method transposes to transfer the records from the import set source Import Set table to the target table. It uses the active transform map, which is located in the Transform Maps (sys_transform_map) table.

  • source – the current import table
  • target – the destination import table.

The record parameter must be the entry from the Import Set (sys_import_set) table.

A transform map is a set of field map records that determine how the fields of the import table and correspond to the fields of the target table.

Parameter(s):

NameTypeMandatoryDefault
Value
value
recordSimpleRecord objectYN

Return:

TypeDescription
BooleanThis method returns
'
true
'
when the transformation is successful; otherwise, it returns
'
false
'
.

Example:

Code Block
languagejs
themeEclipse
titletransform()
linenumberstrue
const imp = new SimpleImport();
imp.transform(current);


Table of Contents
absoluteUrltrue
classfixedPosition