# FormEvent

# BuildUserProfileFromRecord

## <span class="mw-headline" id="bkmrk-what-it-does-1">What it does</span>

Creates a TS user from data in a record (name, email)

- Creates a user
- Assigns to a group
- Sends profile to user

## <span class="mw-headline" id="bkmrk-how-to-invoke-1">How to invoke</span>

Set the codeunit on the entity to: **dk.p2e.blanket.codeunit.common.BuildUserProfileFromRecord**

## <span class="mw-headline" id="bkmrk-configuration-1">Configuration</span>

Set the folowing configutations

- fieldUserLink
- fieldDataName
- fieldDataMail
- defaultGroupID
- requiredStatusID

## <span class="mw-headline" id="bkmrk-developer-info-1">Developer info</span>

- <span class="mw-headline">Type: [CodeunitFormevents](https://docs.tsnocode.com/books/codeunit-reference/chapter/formevents)</span>
- <span class="mw-headline">Security: None</span>
- <span class="mw-headline">Classpath: dk.p2e.blanket.codeunit.common.BuildUserProfileFromRecord</span>

# Gantt Sync CodeUnit

## <span class="mw-headline" id="bkmrk-what-it-does-1">What it does</span>

This is a codeunit that syncs data from one entity to another.  
It also calculates start/end dates if a duration and only one of the dates are given.  
If all three are given, an error will be thrown.  
It was developed to sync data from a couple of entities to a single one, to display the data as a gantt chart.

#### <span class="mw-headline" id="bkmrk-notes-1">Notes</span>

If a duration field is set in the config, the following logic is used when calculating start and end dates.  
Default is to copy the dates.  
If one of the dates isn't given, then it is calculated based on duration (whole days) and the given date.

All statusIDs have to be set and it isn't possible to map from multiple states to a single state.

## <span class="mw-headline" id="bkmrk-how-to-invoke-1">How to invoke</span>

<span class="mw-headline">\[Steps to enable codeunit\]</span>

## <span class="mw-headline" id="bkmrk-configuration-1">Configuration</span>

<table id="bkmrk-configuration-descri"><tbody><tr><td>**Configuration**</td><td>**Description**</td></tr><tr><td>StructureMigrationCodeUnit.From.Field.Duration</td><td>Name of the column in the database containing the duration of the task (not required)</td></tr><tr><td>StructureMigrationCodeUnit.From.Field.EndDate</td><td>Name of the column in the database containing the enddate of the task</td></tr><tr><td>StructureMigrationCodeUnit.From.Field.Parent</td><td>Name of the column in the database containing the DataID of the parent task</td></tr><tr><td>StructureMigrationCodeUnit.From.Field.Progress</td><td>Name of the column in the database containing the percentage progress of the task</td></tr><tr><td>StructureMigrationCodeUnit.From.Field.Serial</td><td>Name of the column in the database containing the unique "code" of the task</td></tr><tr><td>StructureMigrationCodeUnit.From.Field.StartDate</td><td>Name of the column in the database containing the startdate of the task</td></tr><tr><td>StructureMigrationCodeUnit.From.Field.Title</td><td>Name of the column in the database containing the title of the task</td></tr><tr><td>StructureMigrationCodeUnit.To.Field.EndDate</td><td>Name of the column in the database where the end will be stored</td></tr><tr><td>StructureMigrationCodeUnit.To.Field.Parent</td><td>Name of the column in the database where the DataID of the parent task will be stored</td></tr><tr><td>StructureMigrationCodeUnit.To.Field.Progress</td><td>Name of the column in the database where the percentage progress of the task will be stored</td></tr><tr><td>StructureMigrationCodeUnit.To.Field.Serial</td><td>Name of the column in the database where the unique "code" of the task will be stored</td></tr><tr><td>StructureMigrationCodeUnit.To.Field.StartDate</td><td>Name of the column in the database where the startdate of the task will be stored</td></tr><tr><td>StructureMigrationCodeUnit.To.Field.Title</td><td>Name of the column in the database where the title of the task will be stored</td></tr><tr><td>StructureMigrationCodeUnit.To.Table</td><td>Name of the table in the database where all the tasks will be stored</td></tr><tr><td>StructureMigrationCodeUnit.Value.Parent</td><td>Static value. Use this to staticly set a DataID as parent task for all tasks synced (not required)</td></tr><tr><td>StructureMigrationCodeUnit.From.StatusID.Active</td><td>StatusID from source entity that should be converted to To.StatusID.Active</td></tr><tr><td>StructureMigrationCodeUnit.From.StatusID.Waiting</td><td>StatusID from source entity that should be converted to To.StatusID.Waiting</td></tr><tr><td>StructureMigrationCodeUnit.From.StatusID.Suspended</td><td>StatusID from source entity that should be converted to To.StatusID.Suspended</td></tr><tr><td>StructureMigrationCodeUnit.From.StatusID.Completed</td><td>StatusID from source entity that should be converted to To.StatusID.Completed</td></tr><tr><td>StructureMigrationCodeUnit.From.StatusID.Failed</td><td>StatusID from source entity that should be converted to To.StatusID.Failed</td></tr><tr><td>StructureMigrationCodeUnit.To.StatusID.Unknown</td><td>StatusID from the target entity. Given to tasks that have a status, that isn't defined in the config</td></tr><tr><td>StructureMigrationCodeUnit.To.StatusID.Active</td><td>StatusID from target entity that matches From.StatusID.Active</td></tr><tr><td>StructureMigrationCodeUnit.To.StatusID.Waiting</td><td>StatusID from target entity that matches From.StatusID.Waiting</td></tr><tr><td>StructureMigrationCodeUnit.To.StatusID.Suspended</td><td>StatusID from target entity that matches From.StatusID.Suspended</td></tr><tr><td>StructureMigrationCodeUnit.To.StatusID.Completed</td><td>StatusID from target entity that matches From.StatusID.Completed</td></tr><tr><td>StructureMigrationCodeUnit.To.StatusID.Failed</td><td>StatusID from target entity that matches From.StatusID.Failed</td></tr></tbody></table>

## <span class="mw-headline" id="bkmrk-developer-info-1">Developer info</span>

- <span class="mw-headline">Type: [CodeunitFormevents](https://docs.tsnocode.com/books/codeunit-reference/chapter/formevents)</span>
- <span class="mw-headline">Security: Requires session</span>
- <span class="mw-headline">Classpath: dk.tempusserva.gantt.StructureMigrationCodeUnit</span>

# Recalculate Parent

## <span class="mw-headline" id="bkmrk-what-it-does-1">What it does</span>

A simple codeunit that allows you to force a complete re-calculation of an associated parent record.

## <span class="mw-headline" id="bkmrk-how-to-invoke-1">How to invoke</span>

Set the codeunit Classname of the entity to: **dk.tempusserva.codeunit.common.GenberegnParent**

## <span class="mw-headline" id="bkmrk-configuration-1">Configuration</span>

Set the following entity configuration

- **GenberegnParent.ParentField** Field NAME containing the DataID of the associated record (eg. ParentReference or Lookup DataID)

## <span class="mw-headline" id="bkmrk-developer-info-1">Developer info</span>

- <span class="mw-headline">Type: [CodeunitFormevent](https://docs.tsnocode.com/books/codeunit-reference/chapter/formevents)</span>
- <span class="mw-headline">Security: none</span>
- <span class="mw-headline">Classpath: dk.tempusserva.codeunit.common.GenberegnParent</span>

# LoadInfoFromCVR

## <span class="mw-headline" id="bkmrk-what-it-does-1">What it does</span>

A codeunit that does a lookup via danish CVR register and updates the given fields of the record.

Only the configurations that are set will be updated, allowing for fetching of specific fields.

## <span class="mw-headline" id="bkmrk-first-setup-1">First setup</span>

Add a status action and set the codeunit Classname to: **dk.tempusserva.codeunit.common.LoadInfoFromCVR**

Set the following entity configurations

- **LoadInfoFromCVR.LookupField** Field SYSTEMNAME containing the CVR to be looked up (required)
- **LoadInfoFromCVR.NameField** Field SYSTEMNAME for the field to be populated with the name of the company
- **LoadInfoFromCVR.AddressField** Field SYSTEMNAME for the field to be populated with the streetname and number of the company
- **LoadInfoFromCVR.PostalcodeField** Field SYSTEMNAME for the field to be populated with the zip/postal code of the company
- **LoadInfoFromCVR.CityField** Field SYSTEMNAME for the field to be populated with the cityname of the company
- **LoadInfoFromCVR.EmailField** Field SYSTEMNAME for the field to be populated with the email of the company
- **LoadInfoFromCVR.PhoneField** Field SYSTEMNAME for the field to be populated with the phonenumber of the company
- **LoadInfoFromCVR.FaxField** Field SYSTEMNAME for the field to be populated with the fax of the company
- **LoadInfoFromCVR.EmployeeCountField** Field SYSTEMNAME for the field to be populated with the employee count of the company
- **LoadInfoFromCVR.IndustryCodeField** Field SYSTEMNAME for the field to be populated with the industry code of the company
- **LoadInfoFromCVR.CompanyCodeField** Field SYSTEMNAME for the field to be populated with the company type code of the company

## <span class="mw-headline" id="bkmrk-how-to-invoke-1">How to invoke</span>

<span class="mw-headline">\[Steps to enable codeunit\]</span>

### <span class="mw-headline">Options</span>

<span class="mw-headline">\[Optional options, that can be set at runtime, eg. url-parameters\]</span>

## <span class="mw-headline" id="bkmrk-configuration-1">Configuration</span>

<span class="mw-headline">\[All possible configurations and where to edit them\]</span>

## <span class="mw-headline" id="bkmrk-developer-info-1">Developer info</span>

- <span class="mw-headline">Type: [CodeunitFormevents](https://docs.tsnocode.com/books/codeunit-reference/chapter/formevents)</span>
- <span class="mw-headline">Security: \[eg. requires admin or session\]</span>
- <span class="mw-headline">Classpath: dk.tempusserva.codeunit.common.LoadInfoFromCVR</span>

# Http request on save

<span class="mw-headline">This Codeunit is not ready for use!</span>

## <span class="mw-headline" id="bkmrk-what-it-does-1">What it does</span>

This codeunit is capable of performing an HTTP-request with parameters from the updated item and update the item based on the result.

## <span class="mw-headline" id="bkmrk-first-setup-1">First setup</span>

<span class="mw-headline">\[Optional, if extra config is required to get the codeunit working\]</span>

## <span class="mw-headline" id="bkmrk-how-to-invoke-1">How to invoke</span>

Add the codeunit `dk.tempusserva.codeunit.common.RequestFormevent` to the entity and add a configuration named `RequestFormevent.Setup` with content based on the following configuration.

It is possible to add both a "before-update" and an "after-update" action.

## <span class="mw-headline" id="bkmrk-configuration-1">Configuration</span>

<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>when</td><td>Required</td><td>String</td><td>Possible values: "after-update" or "before-update". Determines whether the call is executed before or after an item is updated.

</td></tr><tr><td>status</td><td>Optional</td><td>Array</td><td>An array of the StatusID's where the call should be executed. If "after-update", then this is if the item is in one of these status's after the update, likewise for "before-update".

If not given, then the call is executed every time.

</td></tr><tr><td>call</td><td>Required</td><td> </td><td>The actual configuration of the call.</td></tr><tr><td>call.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>call.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>call.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>call.headers</td><td>Optional</td><td>Map</td><td>A map of extra headers that should be set</td></tr><tr><td>call.params</td><td>Optional</td><td>Map</td><td>Path parameters that should be set and send.</td></tr><tr><td>call.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>call.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.

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

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

```json
[
    {
        "when": "before-update",
        "status": [69],
        "call": {
            "url": "https://acme.com/resource/[ID]",
            "method": "GET",
            "type": "json",
            "headers": {
                "Authorization": "Bearer XYZ"
            },
            "params": {
                "param": "[DATA]"
            },
            "body": "",
            "update": {
                "[LINK]": "info.link",
                "[NAME]": "info.name"
            }
        }
    }
]
```

## <span class="mw-headline" id="bkmrk-developer-info-1">Developer info</span>

- <span class="mw-headline">Type: [CodeunitFormevent](https://docs.tsnocode.com/books/codeunit-reference/chapter/formevents)</span>
- <span class="mw-headline">Security: requires session</span>
- <span class="mw-headline">Classpath: dk.tempusserva.codeunit.common.RequestFormevent</span>