Skip to main content

Triggers

The triggers allow you to listen to and get notified about any changes in DB tables. You can setup the URL address the change notifications will be sent to and which tables will be monitored.

Important

In order to use triggers first make sure you have a Token, if you do not have one yet, follow the instrctions here.

tip

You can add, edit and delete triggers by going to the the Triggers page in H-Web, click here for more info

Trigger Example

The example below shows the data that's sent when there are changes detected in the accounts table:

{
data: "W3siQWNjb3VudEtleSI6IjEiLCJGdWxsTmFtZSI6bnVsbCwiRHVtaSI6Itek16LXmdecIiwiU29ydEdyb3VwIjozLCJGaWx0ZXIiOiJeXl5eXiIsIkFkZHJlc3MiOm51bGwsIkNpdHkiOm51bGwsIlppcCI6bnVsbCwiQ291bnRyeSI6bnVsbCwiUGhvbmUiOm51bGwsIkZheCI6bnVsbCwiQmFsYW5jZUNvZGUiOjY4LCJCYWxhbmNlIjowLCJDcmVkaXRUZXJtc0NvZGUiOjEsIlRGdGFsRGlzY291bnQiOjAsIlZhdEV4YW1wdCI6Itek15jXldeoINee157Xolwi154iLCJEaXNjb3VudENvZGUiOjAsIldvckYiOm51bGwsIkRldGFpbHMiOm51bGwsIkF2Z0xhdGVQYXkiOjAsIk1heENyZWRpdCI6MCwiTWF4Q3JlZGl0Q3VycmVuY3kiOiLXqVwi15ciLCJTYWxlc0N1cnJlbmN5Ijoi16lcIteXIiwiUHVyY2hhc2VDdXJyZW5jeSI6ItepXCLXlyIsIk9ibGlnbyI6MCwib2JsaWdvRGVsaXZlcnkiOjAsIm9ibGlnb2xheWJ1eSI6MCwiTWF4T2JsaWdvIjowLCJNYXhPYmxpZ29DdXJyZW5jeSI6ItepXCLXlyIsIkN1c3RvbWVyTm90ZSI6bnVsbCwiQXNzaWduS2V5IjpudWxsLCJBZ2VudCI6MCwiRGVkdWN0aW9uUHJjIjowLCJEZWR1Y3Rpb25WYWxpZCI6IjE5ODktMTItMzFUMjI6MDA6MDAuMDAwWiIsIkJEYXRlIjoiMjAyMi0wNS0xOFQyMTowMDowMC4wMDBaIiwiQmFua0NvZGUiOm51bGwsIkJyYW5jaENvZGUiOm51bGwsIkJhbmtBY2NvdW50IjpudWxsLCJUYXhGaWxlTnVtIjpudWxsLCJNYWluQWNjb3VudCI6MjYsIlByb3RlY3RlZCI6MCwiQ29zdENvZGUiOm51bGwsIkRpZmZlckFjYyI6bnVsbCwiRU1haWwiOm51bGwsIkV4RmlsZSI6bnVsbCwidmFyaWV0eUldXJyIjoiJCIsIkRlZHVjdEZpbGUiOm51bGwsIkJvb2tzUGVybWlzc2lvbiI6MSwiUGFydG5lcnNUeXBlIjowLCJEZWR1Y3RUeXBlIjowLCJNYXNhdiI6MCwiTmFtZTEwMDAiOm51bGwsIkFjY0VESSI6bnVsbCwiUG9pbnRzUXVudCI6MCwiRml4ZWRPcmRJCMkJQYXlDQyI6MCwiUHJ0VG8iOjB9XQ==",
// Changed records in base64 format
table: "accounts", // table
db_name: " wizdb886n5", // db name
company_info: {private_company: "5656563", company_vatnum:"123456789"},// company information
fields_changed: { 10001: { City: "Tel-Aviv" } }, // Fields that have changed
date_time: "Sun, 20 Mar 2022 15:37:04 GMT", // Sending time
signature: "3904cadb8a19e800ec1518087faf45", // signature
}

Trigger fields

dataAn array of the changed records, in a base64 format
tableThe DB table in which the changes occurred
db_nameThe DB where the changes occurred
company_info:
private_companyThe company's identification (ח.פ חברה)
company_vatnum Licensed dealer number (מספר עוסק מורשה)
fields_changedDetails of the changes in each record
(see field list here)
date_timeDate and time the trigger was sent
signatureData signature

Data Verification

You can verify the data you've received by submitting the data from body.data along with the Token, if the value that returns is equal to body.signature, the varification succeeded.

const md5 = require("md5");
const signature = md5(`${body.data}${token}`);
if(body.signature == signature)
return true;
return false;

Converting to JSON

If you prefer to get the changes in a JSON format you need to convert the data from base64 to JSON:

 let jsonData = JSON.parse(Buffer.from(body.data, "base64").toString("utf-8"));
console.log(jsonData);

JSON example

[                                   
{
"AccountKey": "10001",
"FullName": null,
"Dumi": "פעיל",
"SortGroup": 55,
"Filter": "^^^^^",
"Address": "Hazait 5",
"City": "Tel-Aviv",
"Zip": "656565",
"Country": "israel",
"Phone": null,
"Fax": null ...
},
],

Trigger Methods

Adding an Address

Sets up the address that will receive updates when a table is changed.

REST APITriggersApi/setURL

Parameters

urlThe address you wish to receive updates to
tableThe DB table you want to listen to changes in
(see table list here)

Example

{
"url":"https://test.co.il/trigerTests/gotAccounts",
"table":"accounts"
}

Deleting an Address

Deletes the address that will receive updates when a table is changed.

REST APITriggersApi/deleteURL

Parameters

urlThe address you wish to delete
tableThe DB table the address was receiving updates from
(see table list here)

Example

{

"url":"https://test.co.il/trigerTests/gotAccounts",
"table":"accounts"
}

Changing the Address or Table

Changes the address that will receive updates when a table is changed, or change the table that's being monitored.

REST APITriggersApi/updateURL

Parameters

field The field you wish to update ("url"/"table")
urlThe current value of the "url" field
This value is used to identify the record to update
tableThe current DB table the address is receiving updates from
This value is used to identify the record to update
(see table list here)
value The new value you wish to update

Example

{
"url":"https://test.co.il/trigerTests/gotAccounts",
"table":"accounts",
"field":"url",
"value":"https://mytest.co.il/trigerTests/gotAccounts"
}

Exporting Address List

Returns all the addresses that are set up in your DB.

REST APITriggersApi/getURL

Tables to Monitor

  • stock - תנועות מלאי -כותרת
  • stockmoves - תנועות מלאי - תנועות
  • accounts - חשבונות
  • items - פריטים
  • jurnaltrans - תנועות יומן - כותרת
  • jurnaltransmoves - תנועות יומן - תנועות
  • bankpages - דפי בנק
note

You won't be notified about changes in the stock and stockmoves tables if they were made on a document that has not yet been produced (temporary document).

Fields

Below is a list of the fields that the fields_changed parameter can return if their data has been changed:

important

Changes in fields that aren't listed here will not activate a trigger.

Accounts

Accountkey, address, avglatepay, balance, balancecode, city, country, credittermscode, datf1, datf2, details, discountcode, fax, filter, fullname, id, maxcredit, maxcreditcurrency, maxobligo, phone, sortgroup, suf1, suf2, suf3, suf4, tftaldiscount, vatexampt, worf, zip Click here for descriptions of Accounts fields



Items

barcode, converf, currency, discountcode, discountprc, dutyprc, dutytype, filter, forignname, id, itemkey, itemname, lastpurchdate, localization, minpurchase, price, productiontime, purchaseunit, purchcurrency, purchprice, quantity, retailtaxprc, salesunit, sortgroup, stocklevel, vatexampt, volume, weight, wholesaletaxprc Click here for descriptions of Items fields



Stock

accountkey, accountname, address, batch, city, copies, details, discountprc, docnumber, documentid, duedate, id, marketingnet, originalprinted, paydate, phone, printstyle, reference, remarks, status, stockbatch, terminaldoc, tftal, tftalvat, tftalvatfree, transtype, valuedate, vatfreetranstype, vatprc Click here for descriptions of Stock fields



Stockmoves

agent, alternum, basedate, baseflag, basemoveid, basequantity, commisionprc, currencycode, details, discountprc, documented, duedate, id, itemkey, itemname, packs, price, quantity, rate, reference, saletaxprc, status, stockid, supplypacks, supplyquantity, tftal, tree, treefathermoveid, unit, vatexampt, warehouse Click here for descriptions of Stockmoves fields



Jurnaltrans

bachno, batchno, changeable, costcode, credittermshare, credname, currencycode, datf3, debname, description, differ, duedate, lockingis, paymentid, quant, ref2, ref3, reference, status, stockid, suf, sufdlr, transcredid, transdebid, transid, transtype, type, usefid, valuedate Click here for descriptions of Jurnaltrans fields



Jurnaltransmoves

accountkey, debitcredit, fullmatch, id, isfrayer, percenf, sourcemoveid, suf, sufdlr, transid Click here for descriptions of Jurnaltransmoves fields



Bankpages

accountkey, balance, creditdebit, datf, details, id, pageno, recon, reconno, recsid, reference, secdate, suf Click here for descriptions of Bankpages fields



Triggers in H-Web

A user with a token can add, edit and delete triggers by using the H-Web application:

Navigation to the Triggers page in the H-Web application

Triggers page in the H-Web application