# Jobs json

## From Inistate to Accounting software

#### Sample Code \[Accounting 1]

Each job entry specifies:

* **name**: Logical name of the task.
* **enabled**: `true`/`false` to turn this job on or off.
* **server**: Connection parameters (host, database, credentials).
* **debug**: Enable detailed logging.
* **hook** / **errorHook** / **callBackHook** : Web hook URLs for sync, error handle and callbacks.
* **lastSync**: Timestamp of the last run.
* **interval**: Polling interval in minutes.

{% tabs %}
{% tab title=" jobs.json" %}
{% hint style="info" %}
Replace respective **Logic script name** in `{LOGIC-NAME}` for hook and errorHook.
{% endhint %}

```
"Logic": [
  {
    "name": "{NAME}",
    "enabled": false,
    "server": {
      "server": "{SERVER}",
      "database": "{DATABASE}",
      "dbUsername": "{DB_USERNAME}",
      "dbPassword": "{DB_PASSWORD}",
      "user": "{USERNAME}",
      "password": "{PASSWORD}"
    },
    "debug": false,
    "hook": "https://api.inistate.com/api/automationHook/hook/{MODULE-ID}-{LOGIC-NAME}",
    "errorHook": "https://api.inistate.com/api/automationHook/hook/{MODULE-ID}-{LOGIC-NAME}",
    "lastSync": "{LAST_SYNC_DATE_TIME}",
    "interval": 5
  }
]
```

{% endtab %}

{% tab title=" jobs.json (with call back)" %}
{% hint style="info" %}
Replace respective **Logic script name** in `{LOGIC-NAME}` for hook, errorHook, and callBackHook.
{% endhint %}

```
"Logic": [
  {
    "name": "{NAME}",
    "enabled": false,
    "server": {
      "server": "{SERVER}",
      "database": "{DATABASE}",
      "dbUsername": "{DB_USERNAME}",
      "dbPassword": "{DB_PASSWORD}",
      "user": "{USERNAME}",
      "password": "{PASSWORD}"
    },
    "debug": false,
    "hook": "https://api.inistate.com/api/automationHook/hook/{MODULE-ID}-{LOGIC-NAME}",
    "errorHook": "https://api.inistate.com/api/automationHook/hook/{MODULE-ID}-{LOGIC-NAME}",
    "callBackHook": "https://api.inistate.com/api/automationHook/hook/{MODULE-ID}-{LOGIC-NAME}",
    "lastSync": "{LAST_SYNC_DATE_TIME}",
    "interval": 5
  }
]
```

{% endtab %}
{% endtabs %}

#### Sample Code \[Accounting 2]

{% tabs %}
{% tab title="jobs.json" %}
(Work In Progress)
{% endtab %}

{% tab title="jobs.json (with call back)" %}
(Work In Progress)
{% endtab %}
{% endtabs %}

## From Accounting Software to Inistate

#### Sample Code \[Accounting 1]

{% tabs %}
{% tab title="jobs.json" %}

```
"SQLSync": [
  {
    "name": "{NAME}",
    "enabled": false,
    "connectionString": "Data Source={SERVER};Initial Catalog={DATABASE};User Id={DB_USERNAME};Password={DB_PASSWORD};",
    "hook": "https://api.inistate.com/api/automationHook/hook/{MODULE-ID}-{LOGIC-NAME}",
    "sql":  "SELECT DocKey,\r\n\t   DocNo,\r\n       SubmitEInvoice,\r\n       EInvoiceStatus,\r\n      
             EInvoiceAIPSubmissionDateTime,\r\n       EInvoiceUuid,\r\n       EInvoiceValidatedDateTime as LastModified,\r\n EInvoiceValidationLink\r\n
             FROM IV Where EInvoiceValidatedDateTime > DATEADD(MINUTE, -5, @date) Order By EInvoiceValidatedDateTime Asc",
    "lastSync": "{LAST-SYNC-DATE-TIME}",
    "debug": false,
    "interval": 5,
    "start": null
  }
]
```

{% endtab %}
{% endtabs %}

#### Sample Code \[Accounting 2]

The `SQLSync` section entry specifies:

* **name:** Logical identifier for the sync job.
* **enabled**: `true`/`false` to turn this job on or off.
* **connectionString**: A valid ADO-style string.
* **hook**: The callback URL to receive each batch of synced rows.
* **sql**: Your SQL script to select changed records.
* **lastSync**: Timestamp of the last run.

{% tabs %}
{% tab title="jobs.json" %}
{% hint style="warning" %}
In order to sync, you must include **`LastModified`** in `sql`
{% endhint %}

```
"SQLSync": [
  {
    "name": "{NAME}",
    "enabled": false,
    "connectionString": "Data Source={SERVER};Initial Catalog={DATABASE};User Id={DB_USERNAME};Password={DB_PASSWORD};",
    "hook": "https://api.inistate.com/api/automationHook/hook/{MODULE-ID}-{LOGIC-NAME}",
    "sql": "{SQL-QUERY-SCRIPT}",
    "lastSync": "{LAST-SYNC-DATE-TIME}",
    "start": null
  }
]
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://inistate.gitbook.io/home/advanced/integration/jobs-json.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
