Toggle menu

History - Write Event

This field creates a history and writes an event to it. It includes properties that let you set the various label values, the event properties, set whether the full form data is saved in the event, control whether the event is public or private, and if the entire history should be sealed or not. The event is logged following server-side validation.

For more information see the History Service documentation and Recording History from Stand-Alone Forms in the knowledge base. 

If your form is part of a workflow process, data can also be written to history without using this field. See the Workflow - Start Action and Workflow - Complete Task Action fields for more information.

Properties

LabelDescriptionType Name
History Label ARequired. The first part of a multi-part key that uniquely identifies a history. This label must be a valid JSON value, ie true, false, null, a numeric value, or a double quoted string. There is a special value, "#FORM_NAME#" that can be used to obtain the name of the form. This is the default.

The value of another field can be used by adding the field's name between # characters, eg "#EMAILADDR#". This must be the complete field name when an external type definition is used.

Maximum 50 characters (take care if you are using the value of another field)
LABELA
History Labels B-EOptional. Part of a multi-part key that uniquely identifies a chain of history events. The label must be a valid JSON value. There is a special value, "#UNIQUE_ID#" that can be used to generate a unique identifier similar to a workflow business key. This is the default for labelb.

The value of another field can be used by adding the field's name between # characters.

Maximum 50 characters (take care if you are using the value of another field)
LABELB, LABELC, LABELD, LABELE
Subject DescriptionThe description held in the subject data packet of the history. If no value is set the description of the form will be used.

The value of another field can be used by adding the field's name between # characters
SUBJECTDESCRIPTION
Subject Additional PropertiesOptional. A function that can be used to either add new properties to, or override existing properties within, the history subject. To add additional properties, return a JSON object from this function. To override existing properties, return a JSON object that includes one or more elements with the same name as an existing property.

See Adding and Overriding Properties below
SUBJECTADDITIONALPROPERTIES
Subject Proxy User IdThis hidden property will store the username of the user that created this history if acting on behalf of another user using the Assisted Service productSUBJECTPROXYUSERID
Subject Site User IdThis hidden property will store the username of the user that created this historySUBJECTSITEUSERID
EventA short one or two word phrase that describes the event. If no value is supplied the string "Form Submission" will be used.

The value of another field can be used by adding the field's name between # characters
EVENTEVENT
Event DescriptionA more detailed human readable description of the event. If no value is supplied the form's description will be used, in the format "Form: [Form description] submitted"

The value of another field can be used by adding the field's name between # characters
EVENTDESCRIPTION
Event History DescriptionOptional. A human readable description of the history as a whole which supersedes the subject description in the Self Service and User Requests products. This is used to provide updated subjects (as the original subject description can't be changed once written).

The value of another field can be used by adding the field's name between # characters
EVENTHISTORYDESCRIPTION
Event User RoleName of the role the user was performing as when they triggered the event. For example, "customer".

The value of another field can be used by adding the field's name between # characters
EVENTUSERROLE
Event PrivateIf true, this event will be marked as private. The Self Service and User Requests products contain configuration options that can show or hide private events.

The value of another field can be used by adding the field's name between # characters
EVENTPRIVATE
Event Additional PropertiesOptional. A function that can be used to either add new properties to, or overwrite existing properties within, the event object. To add additional properties, return a JSON object from this function. To override existing properties, return a JSON object that includes one or more elements with the same name as an existing property.

See Adding and Overriding Properties below
EVENTADDITIONALPROPERTIES
Event Proxy User IdThis hidden property will store the username of the user that created this event if acting on behalf of another user using the Assisted Service productEVENTPROXYUSERID
Event Site User IdThis hidden property will store the username of the user that created this eventEVENTSITEUSERID
Store Form DataIf true, data submitted with the form will be stored within the event. A form could later be populated with this data and displayed to the user as a summarySTOREFORMDATA
Store User DataIf false the proxyUserId and userId won't be written to the historySTOREUSERDATA
Form NameIf Store Form Data is true, this is the name of the form that will be used to display the data. Defaults to the name of the current form if not suppliedFORMNAME
Seal HistoryIf true, the history will be sealed when the event is recorded. When a history is sealed new events can no longer be added to it and it will appear as "Completed" in products like the Self Service template. Do not seal the history when writing to a workflow history, this will be performed automatically by the workflow worker when the process ends.

The default is for the history to be sealed. In most cases this field type will be used to write a single history storing a single form submission
SEALHISTORY
DocumentationAdd documentation to your field to help explain any complex functionality to future users. You might include information on what the field does and how it relates to other fields on the form. Notes added here are only ever visible in the Forms Designer, they can be searched for, viewed and downloaded from the action panel. See Common Field Properties for an exampleDOCUMENTATION

Action Results

The following can be accessed using .utilGetActionResults once the action has been processed.

"FIELDNAME": {
    "eventId": "1027",
    "success": "true"
}

Adding Additional Properties

To add additional properties to an event or the history subject, return a JSON object from the subject/event additional properties functions:

function(helper) {
    var additionalProps = {};
    additionalProps.additionalPropertyKey = "additionalPropertyValue";
    additionalProps.totalCost = parseInt(helper.getFieldValue('PRICE')) * parseInt(helper.getFieldValue('QUANTITY'));
    return additionalProps;
}

Additional Event Properties
 

Overriding Properties

Returning a JSON/JavaScript object with an element that has the same name as the following will override the existing property value:

Overridable Subject Properties: description, userId and proxyUserId.

Overridable Event Properties: event, description, userRole, userId, proxyUserId, and historyDescription.

For example, to set the description dynamically:

function(helper) {
    var additionalProps = {};
    additionalProps.description = helper.getFieldValue('TEXT1');
    return additionalProps;
}

History Event Format

The event written by the field has the following format. The formData property will be absent if the field is not set to save form data. Note how the page name is included with each field name in the form data, as well as the actions that navigated through the form. The default event name and description can also be seen:

"event": {
    "event": "Form Submission",
    "description": "Form: [History write event] submitted.",
    "userRole": null,
    "userId": "TIMG",
    "proxyUserId": null,
    "private": false,
    "formData": {
        "data": {
            "PAGE1.TEXT1": "A value",
            "FORMACTION.NEXT": "HISTORYWRITEEVENT_PAGE1_NEXT",
            "PAGE2.TEXT2": "Another value",
            "FORMACTION.FINISH": "HISTORYWRITEEVENT_PAGE2_SUBMIT"
        },
        "formName": "HISTORYWRITEEVENT",
        "typeName": "FORM_HISTORYWRITEEVENT",
        "formDefinitionType": "FORMDEFINITIONEX"
    }
}

Repeating Pages

The fields from a repeating page are stored as an array of objects, with the field names as the keys:

"formData": {
    "data": {
        "PAGE1": [{
            "NAME": "Tim",
            "AGE": "41"
        }, {
            "NAME": "Leo",
            "AGE": "40"
        }],
        "PAGE2.COLOUR": "Red",
        "PAGE2.SIZE": "Small",
        "FORMACTION.NEXT": "TIMSFORM_PAGE1_FIELD27",
        "FORMACTION.NEXTNOACTIONS": "TIMSFORM_PAGE1_FIELD8_ADD",
        "FORMACTION.FINISH": "TIMSFORM_PAGE2_FIELD30"
    },
    "formName": "TIMSFORM",
    "typeName": "FORM_TIMSFORM",
    "formDefinitionType": "FORMDEFINITIONEX"
}

Last modified on August 08, 2023

Share this page

Facebook icon Twitter icon email icon

Print

print icon