Custom Buttons Examples
Custom Buttons builds a Button Bar from data at the moment the form opens. You design one template button, tell the bar where its data comes from, and every row of data becomes a copy of the template. The two examples below use the same target, a Text Label that reports which button was clicked, so the only difference between them is where the data comes from.
How the template works
- The last option in the bar's Options list is the template. Any options before it stay on the bar exactly as typed, so static buttons go first and the template goes last.
- Each row of data has a value and a display text. Write [DATAVALUE] wherever you want the value and [TEXTVALUE] wherever you want the display text, in the template's Name and in the Value of its Set Field Value action.
- When the form opens, the bar makes one copy of the template per row, fills in the two tokens, and removes the template itself.
- The tokens are filled when the form opens, not when a button is clicked. A button carries its own value from then on.
- If the source returns no rows, nothing is generated and the template stays on the bar as typed, tokens included. Open the form from a record that has the data, or give the template a Show When condition that hides it when the data is missing.
Set up the label
Both examples start with the same label.
- Add a Text Label to the form.
- Set its Field Name to Picked. The Button Bar will find the label by this name.
- Set its Default Value to Nothing picked yet.
Example 1 - One button per value of a field on the record
The record's Approver field holds several names, one stored value per approver. The bar shows one button per approver and the label reports the one that was clicked.
- Add a Button Bar below the label.
- On the Settings tab, click Add Action to create one option and fill it in as follows.
- Name: [TEXTVALUE]
- Type: Set Field Value
- Field: Picked
- Value: You picked [DATAVALUE]
- Save the option. Because it is the only option, it is the last one and therefore the template.
- On the Display tab, set Option Display to Options as Buttons (stacked) so the names read as a list. Any display style works.
- On the Advanced tab, expand Custom Buttons and set Dynamic Source to [JOIN(Approver|;)]. Leave Row Delimiter and Value Delimiter empty so the defaults apply, a semicolon between rows and a caret between the parts of a row.
- Save the form and open it from a record that has several Approver values.
The bar shows one button per approver. Clicking a button changes the label to "You picked" followed by that approver's name.
How it works: [JOIN()] gathers every value stored under the field name and joins them with the character you give it, so [JOIN(Approver|;)] returns the approvers separated by semicolons, which is exactly the row format the bar expects. Write the field name bare inside JOIN, as Approver, not [Approver]. Bracketing it would resolve the field to a single value before JOIN sees it, and only one button would appear. Because each row is a plain name with no caret in it, the value and the display text are the same, so [DATAVALUE] and [TEXTVALUE] give the same result here.
Things to watch:
- The form must be opened from a record. Opened on its own, there is no record to read the approvers from, the source returns nothing, and the template shows as typed.
- If a value could itself contain a semicolon, choose a different separator in both places, for example [JOIN(Approver|~)] with Row Delimiter set to ~.
Example 2 - One button per record of another Record Type
A Departments Record Type has a DeptCode field and a DeptName field. The bar shows one button per department with the name on the button, and the label reports the code of the one that was clicked.
- Find the Record Type's ID. It is the first column of the list in Admin > Record Types. This example uses 12.
- Add the label and the Button Bar exactly as in Example 1, with the template option's Name set to [TEXTVALUE], its Type to Set Field Value, its Field to Picked and its Value to Department code [DATAVALUE].
- On the Advanced tab, expand Custom Buttons and set Dynamic Source to [DMGETOPTIONS(12|0|Status=Active|DeptCode|DeptName)]. Leave the delimiters empty.
- Save the form and open it.
The bar shows one button per active department, labeled with the department name. Clicking a button changes the label to "Department code" followed by that department's code.
The parts of [DMGETOPTIONS()], in order and separated by a vertical bar:
- The Record Type ID to search.
- The maximum number of records to return. Use 0 for no limit.
- The search criteria, written as field=value. Join several with a caret, as in Status=Active^Region=West. Leave it empty to return every record of the type, which makes the source [DMGETOPTIONS(12|0||DeptCode|DeptName)].
- The field whose value becomes [DATAVALUE].
- The field whose value becomes [TEXTVALUE].
- Optional. The field to sort by. When left out, the buttons are sorted by the display field.
- Optional. true to drop rows whose value repeats, so a code that appears on several records makes one button.
How it works: the search runs each time the form opens and returns one row per matching record, already in the bar's row format with the value first and the display text second. A department added later appears the next time the form is opened.
Things to watch:
- The field names inside [DMGETOPTIONS()] are the names on the Departments records, written bare. To search by a value from the current record, bracket only the value side, as in Region=[Region].
- The results depend on the rights of the person opening the form. Someone who cannot see a department's record will not get a button for it.
Going further
To run a whole list of actions when a button is clicked rather than update a label, point the template's Set Field Value action at a Multi-Action field instead of the label, and pass [DATAVALUE] as the Value. Setting a Multi-Action field's value runs its actions, and inside those actions the clicked value is available as [DataValue]. That keeps every button on the bar identical and puts the real work in one place. Multi-Action Fields describes how the actions are set up.