# Status

# Status Actions

The actions are fired when a certain condition is meet AND the item is in the parent status

- An item enters the status
- An item leaves the status
- Time has passed while an item was in this status

### <span class="mw-headline" id="bkmrk-timed-actions-1">Timed actions</span>

The time specified is relative to a value of the item

- Creation date
- Last change
- Last status update
- Dynamic **date field**

Time is specified in days and can assume both negative and positive values.

## <span class="mw-headline" id="bkmrk-action-types-1">Action types</span>

### <span class="mw-headline" id="bkmrk-notification-1">Notification</span>

This action sends an email for users or groups.

Various options for the target email exists, including

- Raw email: Static reference
- User: A specific user in the database
- Field value: The contents of another field 
    - Email
    - Phone (sent by SMS)
    - CPR nr (sent by eBoks)

Different types of content can be included in the emails

- Data from the record
- Document generated using data of the record
- Links to the record (internal users)
- Interface tokens (external users)

Read about special tags and formatting her [Tutorial/Status\_notifications](https://wiki.tsnocode.com/index.php?title=Tutorial/Status_notifications "Tutorial/Status notifications")

### <span class="mw-headline" id="bkmrk-task-create-1">Task create</span>

This will dynamically create new tasks for any '[Task list](https://wiki.tsnocode.com/index.php?title=FieldTask "FieldTask")' fields found in the solution.

### <span class="mw-headline" id="bkmrk-codeunit-1">Codeunit</span>

This action triggers the execution of a special codeunit: [Codeunit/Statusaction](https://docs.tsnocode.com/books/codeunit-reference/chapter/statusaction "Codeunit/Statusaction").

Except for timed actions you would implement this inside a [Codeunit/Formevents](https://docs.tsnocode.com/books/codeunit-reference/chapter/formevents "Codeunit/Formevents").

### <span class="mw-headline" id="bkmrk-export-1">Export</span>

The template is optional: If no template is found raw XML will be generated (FTP/mailto will not work).

The following types of routing are supported for template based exports

- Local file system (optionally a mapped share)
- Remote FTP server
- Sent by email

Please note that export actions are handled in seperate threads (performance), and there is no guarantee the operation succeds (tjeck the event log)

#### <span class="mw-headline" id="bkmrk-values-from-record-1">Values from record</span>

The target reference may contain field references in the {FIELD} format, that will be populated at runtime.

Other special tags include

- {SagID}
- {DataID}
- {Resume}
- {NanoTime}

Note that values in records are not filtered for illegal og troublesome characters (such as \\ or . )

#### <span class="mw-headline" id="bkmrk-usage-examples-1">Usage examples</span>

<table id="bkmrk-routing-syntax-synta"><tbody><tr><th>Routing</th><th>Syntax</th><th>Syntax example</th></tr><tr><td>File system</td><td>*local filesystem path*</td><td>c:\\exportFolder\\{GROUP}\\{TITLE}.docx</td></tr><tr><td>FTP server</td><td>*ftp location and connection string*</td><td>[ftp://username:password@acme.com/exportFolder](ftp://username:password@acme.com/exportFolder)</td></tr><tr><td>Send by mail</td><td>"mailto:"+\[email\]+":"+\[subject\]+":"+\[filename\]</td><td>[mailto:boss@acme.com:Attention:your\_2013\_report](mailto:boss@acme.com:Attention:your_2013_report)</td></tr></tbody></table>

### <span class="mw-headline" id="bkmrk-shift-status-1">Shift status</span>

A status merely changes the status to a new value.

This type of action only makes sense to use in timed actions.

### <span class="mw-headline" id="bkmrk-webhook-1">Webhook</span>

This action performs an HTTP-request with parameters from the updated item and update the item based on the result.

<table class="wikitable" id="bkmrk-datapoint-%C2%A0-type-not"><tbody><tr><th>Datapoint</th><th> </th><th>Type</th><th>Notes</th></tr><tr><td>url</td><td>Required</td><td>String</td><td>The url that is to be called. This supports input of parameters from the item.</td></tr><tr><td>method</td><td>Optional</td><td>String</td><td>The HTTP-method of the call, one of: "POST", "GET", "PUT" or "DELETE". Default: "GET".</td></tr><tr><td>type</td><td>Optional</td><td>String</td><td>The datatype of data returned, supported types: "json", "raw" or "XML". Default: "json".</td></tr><tr><td>headers</td><td>Optional</td><td>Map</td><td>A map of extra headers that should be set</td></tr><tr><td>params</td><td>Optional</td><td>Map</td><td>Path parameters that should be set and send.</td></tr><tr><td>body</td><td>Optional</td><td>String</td><td>A string that will be set and send. Not available for "GET".</td></tr><tr><td>update</td><td>Optional</td><td>Map</td><td>Fields that should be updated based on the data returned. If type is "raw", only the first item in this list will be updated, and it will be set to the entire response.

If type is "json", attributes with keys formatted as `[FIELDNAME]` will be updated from the given key in the returned data.

</td></tr></tbody></table>

In `params` and `body`, values formatted as `[FIELDNAME]`, will be filled with data from the record.

#### <span class="mw-headline" id="bkmrk-sample-1">Sample</span>

```
{
  "url": "http://localhost:3001/users/1",
  "method": "PUT",
  "type": "json",
  "headers": {
    "authorization": "Bearer XYZ",
    "Content-type": "application/json"
  },
  "params": {
    "param": "DATA"
  },
  "body": {
     "id": 1,
     "name": "[NAME]",
     "email": "john.doe@example.com"
  },
  "update": {
    "[NAME]": "name"
  }
}
```

# Status Notifications

## <span class="mw-headline" id="bkmrk-special-tags-for-not-1">Special tags for notification</span>

### <span class="mw-headline" id="bkmrk-data-in-emails-1">Data in emails</span>

Dynamic field content can be inserted using {FIELD\_SYSTEM\_NAME} syntax.

For status notification content the following tags will also be populated

- {USER}: Name of the user
- {RESUME} Name of the record
- {LINK}: Clickable link to the record (se below)
- {NOLINK}: Do not include any record links
- {RAWLINK}: Link without any HTML markup

Note that a link to record will be included at the bottom of the message, unless a LINK, RAWLINK or a NOLINK placeholder can be found.

### <span class="mw-headline" id="bkmrk-create-attachments-1">Create attachments</span>

Additionally rendered files can be attached using the following syntax

```
[REPORT:123456]
```

The number refers to the ID of the template to render.

This will render the the template, and attach the resulting file as an attachment to the email.

Default name of the file is "attachment". In case you want a custom name add this in the tag (ex. "Foobar" )

```
[REPORT:123456-Foobar]
```

Tip: It is perfectly OK to use templates with any tags in it, but in that case you might consider using the link approach below.

Files from the record can be attached using the following tag, where 123456 is the ID of the field.

```
[FILES:123456]
```

### <span class="mw-headline" id="bkmrk-dynamic-links-1">Dynamic links</span>

URLs can be entered by using {APPURL} in front of a relative reference. Example:

```
{APPURL}/login
```

### <span class="mw-headline" id="bkmrk-static-file-links-1">Static file links</span>

If you only need static files, just upload them to the media library and put a link in the mail

1. Upload to media library: Ressources &gt; Media files &gt; Add
2. After upload right-click "show" button and select "copy link"
3. Paste the link into a notification (no html encoding is needed)

Note that this will only make a link to the file (the file is not added as an attachment).