An administrator can send a JSON message to another system when a product is saved in fmcgProducts. fmcgProducts sends the message as an HTTP POST after the product has been saved. A failed call does not undo the save.
To receive product data on a schedule, or to push data in yourself, use the API: Integration with fmcgProducts and fmcgProductsIntegrator from external systems.
Create a webhook event
Open Setup, then Webhook events. This menu is shown to an administrator.
- Choose Create webhook event.
- Fill in Title. This name is shown in the list.
- Fill in Webhook URL. This is the address that receives the POST. The address can include a query string.
- Leave Disabled? unticked. Tick it when you want to keep the event without sending it.
- Choose Save.
The tools menu has New copy. The copy's title ends with Copy. An administrator can delete an event from the same menu.
Choose what is sent
Under Content, choose the product fields in Included fields in JSON. Each field is sent as a property named with its field id, for example D8165.
- A grid is sent as one property per row: D8007_1, D8007_2, and so on.
- An empty field is sent as an empty string.
- A list sends its first value.
- Tick Display value under Use 'display value' for keywords to send the keyword text. Leave it unticked to send the stored code.
Hard coded fields and values in JSON adds properties that are the same on every call. Choose the plus sign, then fill in Key and Value. Both are required, and you can add up to 30 rows. The values are sent as written. A key with the same name as a selected field replaces that field.
Hard coded HTTP headers and values adds HTTP headers in the same way, up to 30 rows. Use a row for an authorization header or a similar token.
The JSON also includes source, the address of the product page, when you save from that page.
Choose when it is sent
Under Trigger, tick at least one entry in Unit type(s). With none ticked, the webhook is never sent.
- Base unit matches a base unit or each.
- Case matches a case, an inner pack, or a display.
- Pallet matches a pallet.
Under Event, tick When created to send only when the product is created. Leave it unticked to send when the product is created and on later saves.
Logic is a formula that must be true or false. Leave it empty to send for every matching product. This sends only for target market 208:
D8255 = "208"
Use & for and, and | for or. The formula uses the same field ids as the product. If the formula cannot be read, an error is shown when you save. Correct the formula. The webhook event is still saved.
Store the reply
Under Response, you can write the result back onto the product.
- Store timestamp for latest run in this field receives the date and time of a successful call.
- Store response from latest run in this field receives the reply text.
A call is successful when the other system answers within 2 minutes with a status below 400. A timeout, a lost connection, or a status of 400 or higher writes nothing back. The failure is recorded in the server log.
Comment under Miscellaneous is a note for administrators. It is not sent.
When the webhook runs
The webhook runs after you save a product on the product page and the save stores a change. The product's unit type must match, When created must match if you ticked it, and Logic must be empty or true. The event must not be disabled, and Webhook URL must be filled in.
The call runs after the save. If several events match, each one is called. While a call for that event and that product is still running, a second call for the same pair is skipped.
A webhook is not sent in these cases:
- Excel import, imported files, and mail import.
- The JSON API, including a batch update.
- A test save.
- A save that stored no change.
- Related units that are recalculated because of the save. The webhook is for the product you saved.
The other system should accept a JSON POST and answer within 2 minutes.