# $create() Fields

This keyword generates a link to a news instance of a definition that is pre-filled with the values given as arguments.

# Usage:

$create(def_id, target_Field_1 = local_field, target_Field_2 = 'literal value', etc...)

Whereas the first argument needs to be the id of the definition from which we want to create a new instance, the other arguments assign the given values to the appropriate fields of the instance to be created. The assigned values can either be local field values or literal values.

TIP

Do note that the id of the first argument can be either of the same or of another definition. The $create() keyword can thus be very useful when you want to implement a link that, when clicked, clones a given instance of the same definition.

WARNING

Please be aware that the new instance that is created once you click on the link included in the details page of the original instance will only have the fields given as arguments of the $create() keyword automatically pre-filled once an id is assigned to it - i.e., once you have actually saved the data.

# Examples:

In the example included below, while we assign as the first argument of the keyword the id number of the Satisfaction Survey definition, as the second argument we are stating that the Person Name field of that definition will be automatically filled with the employee id relative to each different instance of the Employee definition. This is because Person Name is a field built with the $ref keyword, meaning it allows us to search for references to instances of Employee. Finally, in the third argument we are stating that the Contact field of Satisfaction Survey will be automatically filled with the Mobile number stored in each instance of the Employee definition:

$create(195,Person Name=id,Contact=Mobile)

Once we create the Survey this employee field in the Employee definition and save the changes made, a link to create a new instance of the Satisfaction Survey will be displayed below all the other fields with the name of the field rendered in caps: SURVEY THIS EMPLOYEE.

When the link is clicked, the instance will already be filled with the appropriate data concerning that particular employee, according to the data entered as arguments of the $create keyword in the Survey this employee field.

From the video included below, you can see a live example of the $create keyword and its arguments in use: