2020.2

Table Of Contents
Handling the save and restore events
The code inside the function callback of the added event listeners should respond to the event,
by saving or retrieving custom information, respectively.
When the COTG app saves the Form, you can store extra information in the
event.detail.state object as follows:
event.detail.state["key"] = value;
The key can be any string, as long as that string isn't the same as the ID of one of the widgets
on the Form.
In the code that handles the olcotgrestorestate event, use the same key to retrieve the stored
information.
The following sample saves the value "test" using "myString" as the key, when the Form is
saved:
window.addEventListener("olcotgsavestate", function(event) {
event.detail.state["myString"] = "test";
});
The following code retrieves the value that was stored with the myString key and displays it in a
paragraph (a <p> element) at the top of the form.
window.addEventListener("olcotgrestorestate", function(event) {
var value = event.detail.state["myString"];
$("form p").html(value);
};
Note
When you've used jQuery to register for the events - $(window).on() - you must use
event.originalEvent in the event handler functions, for example:
$(window).on("olcotgsavestate", function(event) {
event.originalEvent.detail.state["mywidget"] = "test";
});
Restoring widgets
When a COTG Form is reopened, the app restores all input fields and widgets that were
already present in the original Form (i.e. the Form deployed via Workflow or sent as test using
Page 595