update_derived_value_elementAdmin-only MCP tool.
Update an existing Derived Value Element in a Formulize form.
Element: Derived Value (derived)
Description: An element that derives its value from other elements using custom PHP code. This element allows for calculations or data manipulations based on the values of other form elements. Derived values are automatically recomputed when entries are saved, and in most situations they are also automatically recomputed when connected entries are saved. For example if you have a Workshops form connected to a Bookings form, and the Workshops form has a derived value to keep track of the number of spaces available. The derived value will be updated whenever the Workshop entry is saved, and also whenever connected entries in the Bookings form are created or updated.
When derived values are recomputed, a dataset will be made available to the code in the derived value element. The dataset will contain all the data in the entry being saved, plus all the data from connected entries in other forms. To access this data, use PHP variables named after the element handles, ie: $workshop_name, $booking_date, etc. These variables will resolve to the value(s) of that element in the current dataset. There may be multiple values for a given element in the dataset. In that case, the variable will resolve to an array of values; otherwise it will be a scalar. Use is_array() to detect whether an element has multiple values at present or not.
For more details on the internal Formulize API functions and methods you can use in this code, use the get_documentation tool.
Examples:
| Property | Type | Required? | Description |
|---|---|---|---|
| element_identifier | string or integer | Required | |
| caption | string | Optional | Optional. The new label for the Derived Value Element as it will now appear to users in forms. |
| properties | object | Optional | Optional. Updated configuration settings for the Derived Value Element. The available properties depend on the element type. See the tool description for examples of what properties are needed for different element types. Use the get_form_details tool to see all the element types for the existing elements. |
| column_heading | string | Optional | Optional. The heading to use at the top of a column in lists of entries. If not specified, the caption will be used. Some captions are long and descriptive, and a shorter heading would be more appropriate for in a list of data. |
| help_text_for_users | string | Optional | Optional. A longer description or help text for the Derived Value Element, shown to users filling out the form. This is NOT an internal notes field, this content appears as part of the element. |
| principal_identifier | boolean | Optional | Optional. Whether the Derived Value Element is the principal identifying element for entries in this form. Principal identifiers are used in various places in Formulize to represent an entry. The Principal Identifier would typically be a ‘Name’ text box or other element that unique identifies the entry. Each form can only have one Principal Identifier. If a form has a Principal Identifier, and another element is created or updated with this value set to true, the existing Principal Identifier will be replaced with the new one. Default: false. |
| disabled | boolean | Optional | Optional. Whether the Derived Value Element element is disabled (visible but not usable) in the form. Default: false. |
| display | boolean | Optional | Optional. Whether the Derived Value Element is displayed in the form or hidden. Default: true. |
| display_conditions | array of object | Optional | Optional. A given form entry must meet these conditions in order for this element to be displayed; otherwise it is not shown. Each condition includes an element, an operator, a value, and a ‘type’ flag indicating the logical set the condition belongs to: ‘match-all’ or ‘match-one-or-more’. Multiple match-all conditions are joined with a logical AND operator, and multiple match-one-or-more conditions are joined with a logical OR operator. Only include this property when you intend to change the conditions: omit it entirely to leave any existing conditions unchanged; provide the list of conditions to set or replace them; or provide an empty array ([]) to remove all conditions so the element is always displayed. When setting conditions based on linked elements, do not use foreign keys as values, and instead use the readable value which this tool understands automatically. Use the special value “{BLANK}” (without quotes) to match blank values.
|
| placement | string | Optional | The canonical position of the element in the form. This order is used on every form screen page that this element has been added to (newly created elements are automatically added to all pages that currently have all existing elements; to add an element to a page that has only some existing elements, use the update_form_screen tool). Use “top” to make this element the first element in the form, use “bottom” to make this element the last (which is the default for new elements), or use an element handle to place this element immediately after that element (based on the live state of the form at the time of this specific request; re-fetch get_form_details first if you need to see the current element order). On updates, omit this to leave the current position unchanged. |
| data_type | string | Optional | Optional. The MariaDB data type to be used for the field in the database where this data will be stored. The system will default to text in most cases, but will set smart defaults if the type is specifically a number box or a linked element storing foreign keys, etc. Generally this does not need to be specified, but can be used if the user has specifically stated that a certain data type must be used for a given element. Valid types are: text, int(x), decimal(x,y), date, datetime, time, char(x), varchar(x). For int(x), the x is the number of digits to display in MariaDB when showing the number. For decimal(x,y), the x is the total number of digits, and y is the number of digits after the decimal point. For char(x) and varchar(x), the x is the maximum number of characters to store. |