CLIPBOARDCOPY function
Text
The text string to copy to the clipboard.
Returns
A promise, which succeeds with no value if the text string is copied successfully and fails otherwise. Pass this promise as the first parameter to AWAIT (and related functions) to take action after the promise has succeeded or failed.
Copies a text string to the clipboard. CLIPBOARDCOPY("Copied!")CLIPBOARDCOPY("Copied!") puts the text string "Copied!" on the clipboard. To copy the value of the text field TextField1, use CLIPBOARDCOPY(TextField1)CLIPBOARDCOPY(TextField1).
This function can only be used from an action formula. It is typically invoked from a formula associated with the OnPress property of a formula button.
If the value to copy is not a text string, convert it first using TOTEXT. These two formulas copy "3.14" and "TRUE", respectively, to the clipboard (provided that the language settings of the app use a decimal point and not a decimal comma):
To copy the value of the number field NumberField1 to the clipboard, use this formula:
TOTEXT does not offer much in the way of customization when converting numbers to text strings. FORMATNUMBER, however, has many such options.
This formula formats the value of NumberField1 with a leading "$" currency symbol and rounds it to two decimal places:
Number fields support the FormattedValue property, which returns the value of the field as a formatted text string, using the same settings as when it is displayed in the app.
This formula copies the formatted value to the clipboard:
Copying values from embedded apps
An embedded app runs in an iframe
on the host page. Many web
browsers prevent such apps from copying content to the clipboard.
To fix this issue, add allow="clipboard-write"
to the list of
attributes for the iframe
element:
<iframe seamless
src="https://connect.calcapp.net/?app=abc123"
allow="clipboard-write">
</iframe>
Examples
Copies the text string "Copied!" to the clipboard.
Copies the value of TextField1 to the clipboard.
Copies the value of SwitchField1 to the clipboard. TOTEXT must be used when copying values which are not already text strings.
Copies the value of NumberField1 to the clipboard. TOTEXT can convert not only logical values to text strings, but also numbers.
Copies the value of NumberField1 to the clipboard, rounded to use at least one decimal place and at most four decimal places, depending on the number. FORMATNUMBER provides many more options for formatting numbers than TOTEXT.
Copies the value of NumberField1 to the clipboard, formatted with the same settings used when displaying the value in the app.
Copies the text string "Result:", followed by a line break and the value of NumberField1, to the clipboard. When joining text strings together with the & operator, TOTEXT is invoked automatically on values which are not text.
Copies the value of NumberField1 to the clipboard. When the copy operation is done, a banner with the text "The value has been copied" is shown using the BANNER function.