Information entered in a context can be transferred automatically to its subcontexts, its tasks and its forms. The name of a vessel, a customer, customer numbers etc. are examples of such information. It can be automatically filled out in the forms so users do not have to find and enter this information themselves in the Next app. We call this time-saving “trickle-down” system for inheritance, and the data to be inherited for autofilled meta data.
Note: The configuration of inheritance into tasks and forms involves editing JSON notation. If you are not familiar with this, please contact Zegeba Support to get help. We will develop the procedures described further in upcoming releases.
Inheritance from a context to a subcontext is described in Managing: 8.3 Adding Meta Data for a context type.
Inheritance from contexts to task titles
Inheritance from a context to a task title is done through the parameter ${contextMeta.elementID}. The elementID can be found in the Context Type Editor, in the tab Meta Data. This can then be used in the Task Template Editor‘s Task Description tab.
In the example below the ID in the Context Type Editor was meta.country so in the Task Template Editor we added the parameter ${contextMeta.country}:
In the Next app a task for the country Mali will with this title and description setup looks like this:
Prefill from contexts to task forms
To illustrate this type of inheritance we will use the context type Vessels. There are 2 meta data values that we want to inherit from contexts to task forms: Vessel and Customer. In the Context Type editor’s “Meta Data” tab we can find the element IDs for these: meta.vessel and meta.customer:
You can of course select more that 2 values to be inherited. The form prefill of these values must then be configured in the task templates associated with the context type in order to be inherited to its tasks. The code for this is entered in the Task Template editor for each template, as described further down.
Prefill from tasks
In addition to the values inherited from the context we would also like to autofill the form with a value entered in the task details (meta data) when issuing a task, the Project Name:
The element ID for this value can be found in the Task Template editor’s tab “Task Description”. Its standard format is meta.<label>. You can click on the label under “Meta Data” to the right to see its ID to the left, inside the bracket ${…}. (Then delete this parameter if you don’t need it.) You can of course select more than 1 value to be inherited.
Using this method, we can see that the ID for Project Name is meta.projectName:
So we’re now setting up two things: prefill into a form from the context and from the task’s meta data.
Configuring the task template
- Go to Tasks in the Dashboard,
find the template that you want to use and select Edit Task Template. - Go to “Settings” and open the Code Editor.
This editor displays the code of the template being edited in JSON,
and should only be used by users who have experience in working with this kind of code.
It is described in detail in Managing: 6.9 Using the Task Template Code Editor. - In the top Task Template window we add the following code at the end:
Values fetched from the context have the ID format contextMeta.label, while those fetched from the task have IDs meta.label. - Press [Save] when you are done.
You can copy the code here and change it to suit your context and task setup – for instance by adding more IDs to the code.
Prefill into the form
The inheritance of these values must then be configured in the forms that are used in this task template.
- Open a form in the Designer,
select the main form element and go to Properties > Other. - Check the value Prefill form with data to open its JSON window.
- Enter the prefill code on the form as shown in the picture below.
The “id” is the element ID used in the form design,
and you must use this in the “key” with task. in front.
This code, with 2 more IDs, can be copied from here, then pasted with Ctrl-V into Prefill data as JSON specification and edited to suit your own setup. You can add as many ID sections as you like.
When this is done for one form and one task template, it can be copied to other forms and templates within this context type.
To recap: the configuration described here means that when a context for a specific vessel and customer is created, and tasks with a specific project name are created for this context, the values Vessel, Customer and Project Name are automatically filled out in the forms in the Next app. In real life there will usually be more than 3 values inherited, so this prefill may save a lot of time and hassle when filling out forms, as well as ensuring that the information entered is absolutely correct.