> For the complete documentation index, see [llms.txt](https://knowledgebase.fabricdata.com/xytech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.fabricdata.com/xytech/webhooks/event-trigger.md).

# Event Trigger

The Webhooks functionality builds on the existing Event Trigger features of Xytech, providing a notification template option where you can assign an Export Adaptor and the payload template.

The Event Trigger defines the criteria that determine when a payload is sent, the method and content of the payload, and the Export Adapter to which it is sent.

* The Event Triggers and Conditions tabs determine the criteria of when to send payloads.
* The Notifications tab determines the method used to send the payload.
* The Notification Template tab determines the destination of the trigger content.

Refer to the ***Online Help*** for more information about Event Triggers and how to configure them.

*Event Trigger*&#x20;

<figure><img src="/files/xkTUHDRFd9jfJxdElrgv" alt=""><figcaption></figcaption></figure>

### Event Trigger options described

<table data-header-hidden><thead><tr><th width="156"></th><th></th></tr></thead><tbody><tr><td><strong>Active</strong></td><td>Select (check) to make this payload active, or deselect (clear) to stop sending messages for this payload.</td></tr><tr><td><strong>Event Code</strong></td><td>Use the event code of NOTIFY</td></tr><tr><td><strong>Event</strong></td><td>Description of the trigger</td></tr><tr><td><strong>Event Type</strong></td><td><p>Select when to trigger:</p><p>INSERT sends messages when a record is first created.</p><p>UPDATE sends messages when a record is modified.</p><p>DELETE sends messages when a record is deleted.</p></td></tr><tr><td><strong>Document</strong></td><td>Select the data object for the trigger.</td></tr><tr><td><strong>Doc Table Name</strong></td><td>Select the sub-table of the document for the trigger.</td></tr><tr><td><strong>Access</strong></td><td>Select Global to trigger payloads for the entire system, or select an access method (Division or Work Group) to limit payloads to a specific subset of the system.</td></tr><tr><td><strong>Division</strong></td><td>When Access is set to Division, select the Division for which payloads will be sent. Only documents related to the selected Division will generate payloads.</td></tr><tr><td><strong>Work Group</strong></td><td>When Access is set to Work Group, select the Work Group for which payloads will be sent. Only documents related to the selected Work Group will generate payloads.</td></tr></tbody></table>

### Conditions

Defines the field conditions that initiate a trigger, such as when a specific field is set or modified.

&#x20;Event Trigger Conditions

<figure><img src="/files/g2fdIlCrZetUxzwCji9K" alt=""><figcaption></figcaption></figure>

### Notifications

Establishes the notification type – select ‘Email/Alert’ for webhooks.

&#x20;Event Trigger Notification Type

<figure><img src="/files/jPi8e7Gh73X3x4w7fr4E" alt=""><figcaption></figcaption></figure>

### Notification Template

Defines the action to take for the trigger.

*Event Trigger Layout for Export Adaptor*

![](/files/sB7d3bHw7eKwqdOdwihA)

### Export Adaptor Trigger Details

Select the Export Adaptor to use.

#### Generate Default Template

Click to generate a standard payload template for the selected Document, Event Type, and Export Adaptor.

If any of the Document, Event Type, or Export Adaptor Type definitions change, you should re-generate the default template which will overwrite the previous template. If manual changes have been made to the template, you can update manually or note the additions prior to regenerating the template and reapply the changes.

#### Export Adaptor Template

* Displays the payload template used to generate the payload.
* Either in JSON or XML format. (The format of the template should match the format specified in the Export Adapter that will use the template.)
* Syntax validation will occur when saving the Event Trigger and you will not be able to save if the template contain invalid JSON/XML syntax.
* Users can add document fields to the payload using the syntax \[table.fieldName]. Additionally, users can drag and drop a field from the Template Fields list on the left into the payload template field. Note. You can only include fields on the template from the primary triggered document and not from related tables.

*Dragging a field from the Template Fields list into the payload template.*&#x20;

<figure><img src="/files/6uVxdpRMzAQfsaEDUdoV" alt=""><figcaption></figcaption></figure>

### Include child-table field values

v11.3

Export adaptor payloads can include an array of values from child tables. The syntax requires the array fields to be nested under child table tags using specific syntax as shown in the example below.&#x20;

```
#[<child table name>]
	<fields>
#[/<child table name>]
```

The JSON syntax must be manually managed around these table tags. You can drag and drop fields from the child table onto the template text area where the prefix syntax of the table name will be automatically applied.

An example Export Adaptor payload template for a Media Order Event Trigger that includes a list of Services and a list of Operations.

```json
{
  "document": "MoMediaOrder",
  "id": "[jm_work_order.wo_no_seq]",
  "idField": "wo_no_seq",
  "details": [
		{
	       "services": [
			    #[mo_service_row]
		        {
		          "description": "[mo_service_row.service_desc]",
		          "service_row_no": "[mo_service_row.service_row_no]"
		        }
			    #[/mo_service_row]
		        ],
			"operations": [
		    	#[mo_operation]
			     {
			           "service_row_no": "",
			           "description": "[mo_operation.trx_resource_code]",
			           "op_no": "[mo_operation.operation_no]"
				 }
				#[/mo_operation]
				 ]
		}
	],
	"type": "UPDATE"
}
```

Note: This will make the template non-JSON standard. The template syntax will be validated as Xytech compliant on save.

Example payload generated:

```json
{
  "document": "MoMediaOrder",
  "id": "109483-1",
  "idField": "wo_no_seq",
  "details": [
    {
       "services": [
               {
          "description": "Color Program/Review - Per Hr",
          "service_row_no": "50094"
        },
              {
          "description": "Color Program/Review - Per Hr",
          "service_row_no": "50095"
        },
              {
          "description": "142 Digital Receipt",
          "service_row_no": "229496"
        }
      
        ],
      "operations": [
                {
          "service_row_no": "",
          "description": "",
          "op_no": "71032"
        },
                {
          "service_row_no": "",
          "description": "",
          "op_no": "71033"
        }
        
      ]
    }

  ],
  "type": "UPDATE"
}

```

Please note that the tables cannot be nested within each other, only one level of sub-tables is supported. No restrictions on which table is used to setup the trigger conditions as the code is document based. In other words, if your document is Media Order, you could use any sub table in the trigger conditions and all the available sub tables could be used in the template.

### Parsing and storing of response payload values

Web hooks includes the ability to store a value(s) received in the response body back into a field from the triggered document.&#x20;

Note: This means that if an Operation in a Media Order generated a trigger, you can update a field in the Operation and not the Media Order or other related documents.

This allows Xytech to store the ID generated by an external system as a result of a web hook POST that creates the record.

Supported is the parsing of scalar and single values to be read and stored. Not arrays or JSON objects.

Can only store values back into the originating document, not related documents.

#### Configure Export Adaptor's response format

The Export adaptor includes a ‘Response Format’ parameter to define the expected response format.

Figure 1 - Response Format&#x20;

<figure><img src="/files/mPtLLeDUinLnYmTySR0R" alt=""><figcaption></figcaption></figure>

If you don’t specify a content type , the default will be plain text. \
The storing of Notes and Blob base64 image values is supported.

#### Event Trigger Response Parsing Template

The Event Trigger includes a new field to define the Export Adaptor’s ‘Response Parsing Template’.&#x20;

Here you will add the parse criteria in the format of:\
&#x20;`<table name.field name> = response.<parse field>`.

Figure 2 - Response Parsing Template&#x20;

<figure><img src="/files/clz0iY63x6inyPxe1pNt" alt=""><figcaption></figcaption></figure>

#### To Parse JSON

Example response payload:

```json
{
    "data": {
        "desc": "This is sample description.",
        "id": "ABCEFJ23454"
    }
}
```

**Note**: always include the response prefix.

If the originating document was Title and you wanted to store the 'id' value into ‘external\_key’, then it would look like this: `[lib_title.external_key] = response.data.id`

You can store more than one value from the response payload:\
e.g.:\
`[table.field1] = response.data.id`\
`[table.field2] = response.data.desc`

#### To Parse XML

To parse an XML response, use XPATH syntax. W3Schools XPath tutorial: <https://www.w3schools.com/xml/xpath\\_intro.asp>

Simple parse: \
`[lib_title.external_key] = response/desc`

An attribute of an element: \
`[lib_title.external_key] = response/catalog/book/@id`

Return all values under /response as text \
`[lib_title.title_desc_2] = response`

Example XML:

```xml
<?xml version="1.0"?>
<catalog>
     <book id="bk101">
        <author>Gambardella, Matthew</author>
        <title>XML Developer's Guide</title>
        <genre>Computer</genre>
        <price>44.95</price>
        <publish_date>2000-10-01</publish_date>
        <description>An in-depth look at creating applications 
        with XML.</description>
     </book>
     <book id="bk102">
        <author>Ralls, Kim</author>
        <title>Midnight Rain</title>
        <genre>Fantasy</genre>
        <price>5.95</price>
        <publish_date>2000-12-16</publish_date>
        <description>A former architect battles corporate zombies, 
        an evil sorceress, and her own childhood to become queen 
        of the world.</description>
     </book>
</catalog>
```

`[lib_title.external_key] = response/catalog/book/@id` returns the first id 'bk101' `[lib_title.title_desc_2] = response/catalog/book[@id='bk102']/title` returns 'Midnight Rain'

#### Text Response

Where a text response is configure, the system will store the whole text payload. \
If the response value returned is too big to store in the target field, it will get truncated. \
Any existing values in the database will get overwritten with the new value.

Example: \
`[lib_title.title_desc_2] = response`

The prefix of 'response' is mandatory to represent the response payload.

#### TIP

It is important to ensure the data type or the target field matches the parsed field.&#x20;

In other words, you will not be able to store a string value into a numeric field.&#x20;

Else you will see a response parsing error in the Exp\[ort Adaptor Log: \
"System encountered problem with saving Parsed Response into Database"


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://knowledgebase.fabricdata.com/xytech/webhooks/event-trigger.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
