Versions Compared

Key

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

...

Create date from current date or using passed arguments.

getCurrentDate(<format>)

Returns handle that encapsulates current date in format <format>

Example Code

getCurrentDate(DATETIMEUtc);

Creates the date data of the DATETIMEUtc format

createDate(<format>, <val1>, <val2>, ...<valn>)

Returns handle that encapsulates date in format <format> constructed using values <val1>, <val2>, ...<valn>

Example Code

tmp = createDate(YYYYMMDD, 1995, 12, 23);
setStringField(55, dateToString(tmp));

Creates a date of the YYYYMMDD format with corresponding values and assigns it to the tmp variable

Converts the value of the tmp variable to string and assigns this string to be the value of field 55

getCurrentDateStr(<format>)

Returns current date in format <format>

Example Code

setStringField(55, getCurrentDateStr(DATETIMEUtc));

Gets a current date as a string and assigns this string to be the value of field 55

createDateStr(<format>, <val1>, <val2>, ...<valn>)

Returns date in format <format> constructed using values <val1>, <val2>, ...<valn>

Example Code

tmp = createDateStr(YYYYMMDD, 1995, 12, 23);]

Creates a date of YYYYMMDD format with corresponding values returns this date as string and assigns it to the tmp variable

Convert from date to string


dateToString(<date handle>)

Returns date in format that was mentioned in getCurrentDate() or createDate() call

Example Code

//see the example of createDate()        
        


dateToString(<date handle>, <format>)

Returns date in format <format>

Example Code

tmp = createDate(YYYYMMDD, 1995, 12, 23);
setStringField(55, dateToString(tmp, YYYYMM));

Creates a date from given data in one format and assigns it to the tmp variable

Field 55 is assigned a value of the tmp varible

Get part of the date - year, month, day, etc.


getYear(<date handle>)

Returns the year of date <date handle>

Example Code

tmp = getCurrentDate(DATETIMEUtc);
tmp2 = getYear(tmp);
setDateField(64, YYYYMMDDLmd, tmp2);

Creates a date handle of the current date

Extracts the year from the tmp variable and assigns it to the tmp2 variable

Sets the value of field 64 to the beginning of current year

getMonth(<date handle>)

Returns the month of date <date handle>

Example Code

tmp = getCurrentDate(DATETIMEUtc);
tmp3 = getMonth(tmp);

Creates a date handle of the current date

Extracts the month value from the tmp variable and assigns it to the tmp3 variable

getWeek(<date handle>)

Returns weekof date <date handle>

Example code

tmp = createDate(YYYYMMWW, 1995, 12, 2);

setStringField(55, getWeek(tmp));

Creates a date handle <date handle>

Sets the value of the tmp variable to field 55

getDay(<date handle>)

Returns day of date <date handle>

Example Code

tmp = getCurrentDate(DATETIMEUtc);
tmp4 = getDay(tmp);

Creates a date handle of the current date

Extracts the day value from the tmp variable and assigns it to the tmp4 variable

getHour(<date handle>)

Returns hour of date <date handle>

Example Code

tmp = getCurrentDate(DATETIMEUtc);
tmp5 = getHour(tmp);

Creates a date handle of the current date

Extracts the hour value from the tmp variable and assigns it to the tmp5 variable

getMinutes(<date handle>)

Returns minutes of date <date handle>

Example Code

tmp = getCurrentDate(DATETIMEUtc);
tmp6 = getMinutes(tmp);

Creates a date handle of the current date

Extracts the minutes value from the tmp variable and assigns it to the tmp6 variable

getSec(<date handle>)

Returns seconds of date <date handle>

Example Code

tmp = getCurrentDate(DATETIMEUtc);
tmp7 = get Sec(tmp);

Creates a date handle of the current date

Extracts the seconds value from tmp variable and assigns it to the variable tmp7

getMSec(<date handle>)

Returns milliseconds of date <date handle>

Example Code

tmp = getCurrentDate(DATETIMEUtc);
tmp7 = getMSec(tmp);

Creates a date handle of the current date

Extracts the mile seconds value from the tmp variable and assigns it to the tmp7 variable

getNSec(<date handle>)

Returns nanoseconds of date <date handle>. Function is available since FIXEdge 6.2.0.

Example Code

tmp = getCurrentDate(DATETIMENanoUtc);
tmp7 = getNSec(tmp);

Creates a date handle of the current date

Extracts the nanoseconds value from the tmp variable and assigns it to the tmp7 variable

Set date part - year, month, day, etc.


setYear(<date handle>, <new val>)

Assign new value <new val> to year of date <date handle>

Note
titleValidation rule

New value must be greater than 1970 and less than 2038


Example Code

tmp = getDateField(64, YYYYMMDDLmd);
setYear(tmp, 1979);
setDateField(64, YYYYMMDDLmd, tmp);

Gets the date value of field 64 in the YYYYMMDD format and assigns it to the tmp variable

Sets the year of the date to 1979 in the tmp variable

Assigns the date from the tmp variable back to field 64

setMonth(<date handle>, <new val>)

Assign new value <new val> to month of date <date handle>

Note
titleValidation rule

New value must be greater than or equal 1 and less than or equal 12


Example Code

tmp = getDateField(64, YYYYMMDDLmd);
setMonth(tmp, 06);
setDateField(64, YYYYMMDDLmd, tmp);

Gets the date value of field 64 in the YYYYMMDD format and assigns it to the tmp variable

Sets the month of the date to 06 in the tmp variable

Assigns the date from the tmp variable back to field 64

setWeek(<date handle>, <new val>)

Assign new value <new val> to week of date <date handle>

Note
titleValidation rule

New value must be greater than or equal 1 and less than or equal 5

Example Code

tmp = createDate(YYYYMMWW, 1995, 12, 2);

setWeek(tmp, 4);

setStringField(55, dateToString(tmp));

Gets the date value of field 64 in the YYYYMMWW format and assigns it to the tmp variable

Sets the week of the date to 4 in the tmp variable

Assigns the date from the tmp variable to field 55 in the string format

setDay(<date handle>, <new val>)

Assign new value <new val> to day of date <date handle>

Note
titleValidation rule

New value must be greater than or equal 1 and less than or equal 31


Example Code

tmp = getDateField(64, YYYYMMDDLmd);
setDay(tmp, 27);
setDateField(64, YYYYMMDDLmd, tmp);

Gets the date value of field 64 in the YYYYMMDD format and assigns it to the tmp variable

Sets the day of the date to 27 in the tmp variable

Assigns the date from the tmp variable back to field 64

setHour(<date handle>, <new val>)

Assign new value <new val> to hour of date <date handle>

Note
titleValidation rule

New value must be greater than or equal 0 and less than 24


Example Code

tmp = getDateField(64, DATETIMEUtc);
setHour(tmp, 10);
 setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Sets the hour of the date to 10 in the tmp variable

Assigns the date from the tmp variable back to field 64

setMinutes(<date handle>, <new val>)

Assign new value <new val> to minutes of date <date handle>

Note
titleValidation rule

New value must be greater than or equal 0 and less than or equal 59


Example Code

tmp = getDateField(64, DATETIMEUtc);
setMinutes(tmp, 20);
 setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Sets the minutes of the date to 20 in the tmp variable

Assigns the date from the tmp variable back to field 64

setSec(<date handle>, <new val>)

Assign new value <new val> to seconds of date <date handle>

Note
titleValidation rule

New value must be greater than or equal 0 and less than or equal 59


Example Code

tmp = getDateField(64, DATETIMEUtc);
setSec(tmp, 20);
 setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Sets the seconds of the date to 20 in the tmp variable

Assigns the date from the tmp variable back to field 64

setMSec(<date handle>, <new val>)

Assign new value <new val> to milliseconds of date <date handle>

Note
titleValidation rule

New value must be greater than or equal 0 and less than or equal 59


Example Code

tmp = getDateField(64, DATETIMEUtc);
setMSec(tmp, 50);
setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Sets the milliseconds of the date to 50 in the tmp variable

Assigns the date from the tmp variable back to field 64

setNSec(<date handle>, <new val>)

Assign new value <new val> to nanoseconds of date <date handle>. Function is available since FIXEdge 6.2.0.

Example Code

tmp = getDateField(64, DATETIMENanoUtc);
setNSec(tmp, 50);
setDateField(64, DATETIMENanoUtc, tmp);

Gets the date value of field 64 in the DATETIMENanoUtc format and assigns it to the tmp variable

Sets the nanoseconds of the date to 50 in the tmp variable

Assigns the date from the tmp variable back to field 64

Change date part with automatic date recalculation

changeYear(<date handle>, <new val>)

Add value <new val> to year of date <date handle>

Example Code

tmp = getDateField(64, DATETIMEUtc);
changeYear(tmp, 2);
setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Adds 2 years to the value of the date in the tmp variable

Assigns the date from the tmp variable back to field 64

changeMonth(<date handle>, <new val>)

Add value <new val> to month of date <date handle>

Example Code

tmp = getDateField(64, DATETIMEUtc);
changeMonth(tmp, 5);
 setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Adds 5 months to the value of the date in the tmp variable

Assigns the date from the tmp variable back to field 64

changeDay(<date handle>, <new val>)

Add value <new val> to day of date <date handle>

Example Code

tmp = getDateField(64, DATETIMEUtc);
changeDay(tmp, 10);
 setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Adds 10 days to the value of the date in the tmp variable

Assigns the date from the tmp variable back to field 64

changeHour(<date handle>, <new val>)

Add value <new val> to hour of date <date handle>

Example Code

tmp = getDateField(64, DATETIMEUtc);
changeHour(tmp, 24);
setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Adds 24 hours to the value of the date in the tmp variable

Assigns the date from the tmp variable back to field 64

changeMinutes(<date handle>, <new val>)

Add value <new val> to minutes of date <date handle>

Example Code

tmp = getDateField(64, DATETIMEUtc);
changeMinutes(tmp, 600);
 setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Adds 600 minutes to the value of the date in the tmp variable

Assigns the date from the tmp variable back to field 64

changeSec(<date handle>, <new val>)

Add value <new val> to seconds of date <date handle>

Example Code

tmp = getDateField(64, DATETIMEUtc);
changeSec(tmp, 3600);
setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Adds 3600 seconds to the value of the date in the tmp variable

Assigns the date from the tmp variable back to field 64

changeMSec(<date handle>, <new val>)

Assign new value <new val> to milliseconds of date <date handle>

Example Code

tmp = getDateField(64, DATETIMEUtc);
changeMSec(tmp, 36);
setDateField(64, DATETIMEUtc, tmp);

Gets the date value of field 64 in the DATETIMEUtc format and assigns it to the tmp variable

Adds 36 milliseconds to the value of the date in the tmp variable

Assigns the date from the tmp variable back to field 64

changeNSec(<date handle>, <new val>)

Assign new value <new val> to nanoseconds of date <date handle>. Function is available since FIXEdge 6.2.0.

Example Code

tmp = getDateField(64, DATETIMENanoUtc);
changeNSec(tmp, 36);
setDateField(64, DATETIMENanoUtc, tmp);

Gets the date value of field 64 in the DATETIMENanoUtc format and assigns it to the tmp variable

Adds 36 nanoseconds to the value of the date in the tmp variable

Assigns the date from the tmp variable back to field 64

Routing functions

getSourceClientId()

Returns Client ID of source

Example Code

clientID = getSourceClientId();

Gets the TA client ID of the session context where the script is applied.

Note: Returns NULL value, if the session is not TA client.

getSourceSessionId()

Returns Session ID of source

Example Code

clientID = getSourceSessionId();

Gets the FIX session ID of the session context where the script is applied.

Note: Returns NULL value, if the session is not FIX session.

getSourceSessionQualifier()

Returns the name of SessionQualifier (String) in case if SessionQualifier is available for source session


Example Code

sessionQualifier = getSourceSessionQualifier();
Gets the SessionQualifier name of the session context where the script is applied.

getSessionParser(<sessionName>)

Returns the ParserID (string value) for the session with the specified <sessionName>

Example Code

ParserID = getSessionParser("SOME_SESSION");

Gets the ID of the parser used for the SOME_SESSION session. 

Note: Returns NULL value if the specified session cannot be found or does not exist.

Info

This function is available since FIXEdge C++ 6.14.2 version.

getSessionParser(<senderCompID>, <targetCompID>)

Returns the ParserID (string value) for the session with the specified <senderCompID> and <targetCompID>

Example Code

ParserID = getSessionParser("FIXEdge","SimpleClient");

Gets the ID of the parser used for the session with SenderCompID = "FIXEdge" and TargetCompID = "SimpleClient".

Note: Returns NULL value if the specified session cannot be found or does not exist.

Info

This function is available since FIXEdge C++ 6.14.2 version.

getSessionParser(<senderCompId>, <targetCompId>, <sessionQualifier>)

Returns the ParserID (string value) for the session with the specified <senderCompID>, <targetCompID>, and <sessionQualifier>

Example Code

ParserID = getSessionParser("FIXEdge","SimpleClient","Q1");

Gets the ID of the parser used for the session with SenderCompID = "FIXEdge", TargetCompID = "SimpleClient", and SessionQualifierValue = "Q1"

Note: Returns NULL value if the specified session cannot be found or does not exist.

Info

This function is available since FIXEdge C++ 6.14.2 version.

isSessionActive(<Session Name>)

Checks is FIX Session with name <Session Name> active

Example Code

active = isSessionActive("SOME_SESSION");
if (active)        
        print("SOME_SESSION active");

Checks if FIX Session with the "SOME_SESSION" name is active

Prints a message

convert(<source protocol>, <target protocol>)

Convert message from <source protocol> to <target protocol>

Example Code

convert("FIX.4.4", "FIX.4.2");

Converts message in the given script context replaces a source FIX44 message with converted to FIX42.

transform(<target protocol>, <target message type>)

Transform message from current script context to<target protocol> <target message type> message

Example Code

transform("FIX.4.2", "8");

Transforms message in the given script context, replaces a source message with transformed to FIX42 MsgType="8".

getMsgBySeqNum(<SenderCompId>, <TargetCompId> , <SeqNum>)

Search for message in session identified as <SenderCompId> and <TargetCompId> pair logs by < SeqNum>

getMsgBySeqNum(<SenderCompId>, <TargetCompId>, <SessionQualifier>, <SeqNum>)

Search for message in session identified as <SenderCompID>/<TargetCompID>/<SessionQualifier> set logs by < SeqNum>

Example Code

getMsgBySeqNum("TestSender", "TestTarget", 12345);

Searches for message with given SeqNum in the session identified by the ‘sender|target’ pair.

Note: FIX Session where search occurs must be active and use persistent storage.

send(<SenderCompID>, <TargetCompID>)

Send a message into session identified as <SenderCompID> and <TargetCompID> pair.

send(<SenderCompID>, <TargetCompID>,<SessionQualifier>)

Send a message into session identified as <SenderCompID>/<TargetCompID>/<SessionQualifier> set.

send(<session source identifier>)

Send a message into session that identified by <sessions source identifier>.

Example Code

send("sender", "target");
send("exchange");

Sends a message into the session identified by the ‘sender|target’ pair.

Sends a message into the session identified by the ‘exchange’ source identifier.

handler(<handler name>, <array of additional parameters>)

Route message into handler <handler name> with array of additional parameters as JSObject (optional)

Example Code

params = [["Storage", "file.txt"], ["ClearTime", "22:00"]]

handler("CMEHandler", params);

Routes a message in the “CMEHandler” handler and sets additional parameters for processing:

Storage = file.txt, ClearTime = 22:00

processNetStatusRequest()

Response Network Status Response message (“BD”) on request

Example Code

processNetStatusRequest();

Replaces a Network Status Request message (“BC”) with Response (“BD”) in the routing

createNotification (<category>, <reason>)

Creates notification message (“C”) with <category>, <reason> then puts it into the routing

Example Code

createNotification("E","Session is rejected"); 
        

Creates a notification message (“C”) with “Status = ERROR”, “Code=201”,  “Reason = Session is rejected” in three entries of group (58).

Note: <category> applies values “N” – NOTE, “W” – WARNING, “E” – ERROR, “F” - FATAL

strategySend (<strategyName>)

Processes a message by strategy that identified by <strategyName>

Example Code

strategySend("OrderFlow5");

Processes a message by the default routing strategy with the “OrderFlow5” name.

Note: only default routing strategies can be used for processing: 
deliveryToStrategy, OrderFlowStrategy and WheelOrderFlowStrategy.

strategyReject (<historyName>, <createBusinessRejectIfFailed>)

Creates reject on message that was stored in history <historyName>, or BusinessReject (MsgType = ‘j’), if <createBusinessRejectIfFailed> is ‘true’ and rejecting has fail. <createBusinessRejectIfFailed> accepts ‘false’ by default if it is absent in parameters.

Example Code

strategyReject("orders", true);

Rejects a message that was stored by some strategy in the ‘orders’ history. Creates ‘j’ Business Reject when message rejecting has failed.

Notes: The method is used only in the default routing. Searching in history processes by the ‘ClOrdID’ key in the original message if its type: ‘D’, ‘AB’ or by ‘OrigClOrdID’ key in original message if its type: ‘AC’, ‘F’, ‘G’. 
Inapplicable for other messages.

serializeMessage()

Returns the string view of the current message. SOH will be used as a delimiter.

Example Code

msg = serializeMessage();
Returns the string view of the message where SOH will be used as a delimiter and saves it into the "msg" variable.

serializeMessage(<tagDelimiter>)

Returns the string view of the current message. A specified symbol will be used as a delimiter.

Example Code

msg = serializeMessage("|");
Returns the string view of the message where "|" will be used as a delimiter and saves it into the "msg" variable.

parseMessage(<msg>)

Parses the specified string message and replaces the current message with the parsed one. After that, the old message will be lost. <msg> is a string view of the message. Only messages with SOH as a delimiter can be parsed.

Example Code

parseMessage("8=FIX.4.4\x019=56\x0135=b\x0149=TESTI\x0156=TESTA\x0134=14\x0152=20030204-09:25:43\x01297=0\x0110=139\x01");


Parses a message from the specified string and replaces the current message with it.

parseMessage(<msg>, <version>)

Parses the specified string message using specified FIX protocol and replaces the current message with the parsed one. After that the old message will be lost. <msg> is a string view of the message and <version> is a session version in FIXEdge.properties. Only messages with SOH as a delimiter can be parsed.

Note

Please note: the next action in the rule will receive the replaced message!

Example Code

parseMessage("8=FIX.4.4\x019=56\x0135=b\x0149=TESTI\x0156=TESTA\x0134=14\x0152=20030204-09:25:43\x01297=0\x0110=139\x01", "FIX44");



Parses a message from the specified string using the FIX44 protocol and replaces the current message with it.

Note

If the 1128 tag is specified in the message for parseMessage(<msg>, <version>) function, then the value of the tag has higher priority during parsing than the version value. For instance:

Code Block
languagejs
themeEclipse
collapsetrue
1128=7 and FIXT11:FIX44 and the message has 1092 tag from FIX 5.0: 
parseMessage("8=FIXT.1.1\x019=114\x0135=D\x011128=7\x0149=TESTI\x0156=TESTA\x0134=2\x0152=20081023-17:03:05\x0111=90001008\x0155=IBM\x0154=1\x0160=20080717-10:00:00\x0138=4000\x0140=1\x011092=0\x0110=171\x01", "FIXT11:FIX44");
- the message is parsed successfully as FIX 5.0.


1128=6 and FIXT11:FIX50 and the message has 1092 tag from FIX 5.0:
parseMessage("8=FIXT.1.1\x019=114\x0135=D\x011128=6\x0149=TESTI\x0156=TESTA\x0134=2\x0152=20081023-17:03:05\x0111=90001008\x0155=IBM\x0154=1\x0160=20080717-10:00:00\x0138=4000\x0140=1\x011092=0\x0110=171\x01", "FIXT11:FIX50");
- the following error appears:
  2017-09-13 11:28:01,558 UTC   ERROR   [JS_interpreter]  3760  C:\B2BITS\FIXEdge\FIXEdge1\conf\parseMessage.js: failed with error: Tag 1092 is not defined for this message type. Parsing stopped at column: 136 in message D with sequence number 2.


Error Handling Functions

getErrorCode()

Returns an error code (integer value) in an undelivered message event

Example Code:

setStringField(58, "Error (" + getErrorCode() + ") " + getErrorText());


This example assigns the values 'error code' and 'error text' to field 58.

As a result of this function, the content of tag 58 inside the FIX message could be, for example,: "Error (500) Internal server error"

getErrorText()

Returns error text (string value) in an undelivered message event

Example Code:

setStringField(58, "Error (" + getErrorCode() + ") " + getErrorText());

This example assigns the values 'error code' and 'error text' to field 58.

As a result of this function, the content of tag 58 inside the FIX message could be, for example,: "Error (500) Internal server error"

History functions

saveToHistory (<historyName>, <keyFields>, <commonFields>, <expireDateTime>)

Insert a new record in history with name <historyName>. Returns true if the function succeeded and returns false otherwise.

  • <keyFields> - is an array of values of KeyField elements from history definition. Usually, it is a list of fields defining the primary key and should be unique across all inserts.
  • <commonFields>-  is an array of values Field elements from history definition. 
  • <expireDateTime> - String with a timestamp with an expire date-time in ODBC History. The expired fields will be erased from history during the ClearHistory procedure. An empty string means there is no expiration date for the record.

The ExpireDateTime field should be defined both in History and in the Database.

If the History was created with the expireDateTime field and the expireDateTime argument of the saveOrUpdate function is absent then the following ERROR is printed to the log on saving a new record to the History:

ERROR History  '<history_name>' unable to insert: the ExpireDateTime filed is not defined!

Info

The ExpireDateTime field of the History is optional since FIXEdge 6.14.0 release. If the History was created without the ExpireDateTime field then all new records will be inserted in it without expireDateTime value specified in the saveToHistory function. In such a case the warning will be logged:

WARN [Save to history]<history_name>':the ExpireDateTime value is passed but the field was not defined. The value is ignored.

For more details about the history definition please see ODBC History

Example Code:

Code Block
languagejs
key = new Array("snd","tgt");
common = new Array("ClOrdID","dest");
saveToHistory("orders", key, common, "20101010-10:52:00");

Insert a new record in the table “orders”.

The inserted data is

Code Block
languagesql
SELECT * FROM orders;
+--------------+--------------+---------+------+--------------------+
| SenderCompID | TargetCompID | ClOrdID | Text | ExpireDateTime     |
+--------------+--------------+---------+------+--------------------+
| snd          | tgt          | ClOrdID | dest |  20101010-10:52:00 |
+--------------+--------------+---------+------+--------------------+

updateHistory (<historyName>, <keyFields>, <commonFields>, <expireDateTime>)

Update a record in history with name <historyName> with Primary key defined in <keyFields> array. Returns true if the function succeeded and returns false otherwise.

  • <keyFields> - is an array of values of KeyField elements from history definition. Usually, it is a list of fields defining the primary key and should be unique across all inserts.
  • <commonFields>-  is an array of values Field elements from history definition. 
  • <expireDateTime> - String with a timestamp with an expire date-time in ODBC History. The expired fields will be erased from history during the ClearHistory procedure. An empty string means there is no expiration date for the record.
    The ExpireDateTime field should be defined both in History and in the Database.
Info

The ExpireDateTime field of the History is optional since FIXEdge 6.14.0 release. If the History was created without the ExpireDateTime field then records in it will be updated without expireDateTime value specified in the updateHistory function. In such a case the warning will be logged:

WARN [Update history]<history_name>':the ExpireDateTime value is passed but the field was not defined. The value is ignored.

For more details about the history definition please see ODBC History

Example Code:

Code Block
languagejs
key = new Array("snd","tgt");
common = new Array("", "dest2");
updateHistory("orders", key, common, "20121221-10:52:00");

updateToHistory function params:

The record in history with primary key SenderCompID=snd and TargetCompID=tgt in the table “orders” is updated.

The column 'ClOrdID' is updated with NULL value, the column 'TEXT' is updated with 'dest2' value.

The ExpireDateTime column value '20101010-10:52:00' is updated with value ‘20121221-10:52:00’.

Code Block
languagesql
SELECT * FROM orders;
+--------------+--------------+---------+-------+-------------------+
| SenderCompID | TargetCompID | ClOrdID | Text  | ExpireDateTime    |
+--------------+--------------+---------+-------+-------------------+
| snd          | tgt          | NULL    | dest2 | 20121221-10:52:00 |
+--------------+--------------+---------+-------+-------------------+

saveOrUpdate(<historyName>, <keyFields>, <commonFields>, <expireDateTime>)

Insert a new record in history with name <historyName>. If inserting fails then try to update a record in history with the name <historyName> with the Primary key defined in the <keyFields> array

Returns true if any of the operations to insert or updates are successful.

Returns false both operations failed

  • <keyFields> - is an array of values of KeyField elements from history definition. Usually, it is a list of fields defining the primary key and should be unique across all inserts.
  • <commonFields>-  is an array of values Field elements from history definition. 
  • <expireDateTime> - String with a timestamp with an expire date-time in ODBC History. The expired fields will be erased from history during the ClearHistory procedure. An empty string means there is no expiration date for the record.

The ExpireDateTime field should be defined both in History and in the Database.

If the History was created with the expireDateTime field and the expireDateTime argument of the saveOrUpdate function is absent then the following ERROR is printed to the log on saving a new record to the History:

ERROR History  '<history_name>' unable to insert: the ExpireDateTime filed is not defined!

Info

The ExpireDateTime field of the History is optional since FIXEdge 6.14.0 release. If the History was created without the expireDateTime field then records in it will be saved or updated without the expireDateTime value specified in the saveOrUpdate function. In such a case the warning will be logged:

WARN [Update history/Save to history] <history_name>':the ExpireDateTime value is passed but the field was not defined. The value is ignored.

For more details about the history definition please see ODBC History

Info

Insert failures will be recorded in the application log.

Example Code:

Code Block
languagejs
key = new Array("snd","tgt");
common = new Array("ClOrdIDUpdated","destUpdated");
saveOrUpdate("orders", key, common, "");

Insert a new record in the table “orders”.

If the record in history with primary key SenderCompID=snd and TargetCompID=tgt exists in the table “orders” then the column 'ClOrdID' is updated with a NULL value, the column 'TEXT' is updated with 'dest2' value for the record.

The ExpireDateTime has an empty value so the record will be not cleaned up

Sample:

Code Block
languagesql
SELECT * FROM orders;
+--------------+--------------+----------------+-------------+----------------+
| SenderCompID | TargetCompID | ClOrdID        | Text        | ExpireDateTime |
+--------------+--------------+----------------+-------------+----------------+
| snd          | tgt          | ClOrdIDUpdated | destUpdated |                |
+--------------+--------------+----------------+-------------+----------------+

getFromHistory (<historyName>, <keyFields>, <columnName>)

Retrieves field value in the history <historyName>. Searching criteria is the <keyFields> for a record and <columnName> for column where value reads. Returns target field value, but if such value wasn't found, returns 'undefined'.

Example Code:

key = new Array("snd","tgt");
time = getFromHistory("orders", key, "ExpireDateTime"); 

Returns the ‘20121221-10:52:00’ value from the record with key (snd,tgt) that has been updated by the previous sample.

Notes: the column which is created by the <expireDateTime> parameter always has the “ExpireDateTime” name in history. 
Other columns have names as described in the history description in BL_Config.xml or as a tag number in string representation if the column name is absent in the history description.

getRecordFromHistory (<historyName>, <keyFields>)

Retrieves an array of the fields from the record with key <keyFields>, located in the history <historyName>. Returns target record, but if such record wasn't found, returns 'undefined'.

Example Code:

key = new Array("snd","tgt");
record = getRecordFromHistory("orders", key); print(record); 

Returns a fields array of the record with the key (snd,tgt), then prints content into a log. 
The result will show “snd, tgt, ClOrdID, dest2, 20121221-10:52:00” if the record (snd, tgt) has been saved and updated by previous samples.

Notes: Empty fields have NULL values and printing represents it as “<null>”.
If <keyFields> is composite, then all fields in the key set should be filled.

removeRecordFromHistory (<historyName>, <keyFields>)

Removes entire record with key <keyFields>, located in the history <historyName>. Returns a number of deleted records.

Example Code:

key = new Array("snd","tgt");
removeRecordFromHistory("orders", key);  

Removes a record with a key (snd, tgt) from the ‘orders’ history.

Notes: If <keyFields> is composite, then all fields in the key set should be filled.

removeRecordFromHistoryByCompositeKey (<historyName>, <keyFields>)

Removes entire record by matching of composite key with <keyFields>, located in the history <historyName>. Returns a number of deleted records.

Example Code:

key = new Array("snd","");
ndeleted = removeRecordFromHistoryByCompositeKey ("orders", key);

Removes all records with keys which have first the “snd” field in a key.

Notes: the composite <keyFields> set should contain at least one field. All empty fields in a key will be ignored in searching.

Security functions

Note
Available since FIXEdge 5.10.1

decryptString(<text>)

Decrypts string using AES 128-bit encryption mechanism. It is useful for encrypted tags (554, 925) in Logon messages.

Example Code:

encryptedPass = getStringField("554");
pass = decryptString(encryptedPass);
Decrypts tag 554 

hashString(<text>)

Calculates SHA256 hash for the sting.

Example Code:

hash = hashString("MyPassword");

Getting hash for the "MyPassword" string.

Note: string for calculating hash should be not "null".

...