Note
All code samples below refer to the skuid
object.
In the v2 API, this object is not directly accessible when working within a browser console—or when referring to another Skuid page runtime.
If you are experiencing issues, use the skuid.runtime API to target the appropriate page context.
skuid.formula¶
Good news, everyone!
We are currently writing more material for our Javascript API. All of the objects and functions you see below are part of Skuid’s public API, even if they aren’t fully documented yet. Feel free to experiment while we write about them—and check back later for updates.
Classes¶
-
class
skuid.formula.
FormulaFunction
(localName, callback, options)¶ Used for constructing formula functions. Once a formula function has been constructed using the
new
keyword:new skuid.formula.FormulaFunction(/**/);
The formula function can then be used declaratively within any formula field in the Composer by prepending the
namespace
option value (followed by two underscores) to thelocalName
option value like so:nameSpace__localName(arg1, ... argN)
The most common ways to insert custom formula functions in Skuid pages are through static resources or In-Line JavaScript resources—not In-Line (Snippet) resources.
Arguments: - localName (string) – The local name of the formula function (without the namespace)
- callback (function) – The JavaScript function that is executed by the formula function
- options (object) –
A JavaScript object with the following properties:
- namespace (string) - A namespace prefix, placed before the localName to ensure that two formula functions with the same local name do not overwrite one another. Defaults to c.
Note
The namespace is required when referencing the formula function. The local name without the the namespace (followed by two underscores) will not resolve correctly and may produce an error.
- numArgs (number) - The number of arguments expected by your formula function. Defaults to 1.
- returnType (string) - The type of value your function is expected to return; valid options are “boolean”, “number”, “string”, or “date”
- namespace (string) - A namespace prefix, placed before the localName to ensure that two formula functions with the same local name do not overwrite one another. Defaults to c.
Example: To use this custom formula function,
1 2 3 4 5 6 7 8 9 10
new skuid.formula.FormulaFunction ( 'APPEND_TEXT', function (fieldName, appendString) { return fieldName + ' ' + appendString; },{ namespace: 'textManipulation', numArgs : 2, returnType : 'string' } );
Enter
textManipulation__APPEND_TEXT('text1', 'text2')
in a formula field within the Composer.If the
namespace
option were not specified, thenc__APPEND_TEXT('text1', 'text2')
would be used instead.