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.Formula(formulaName, formulaFunction, options)

This is used for constructing formula objects. Once a formula object has been constructed, its formula can be used within any formula field in the App Composer.

The most common ways to insert custom formulas in Skuid pages are through static resources or In-Line JavaScript resources—not In-Line (Snippet) resources.

Arguments:
  • formulaName (string) – The name of the formula
  • formulaFunction (function) – The function that is executed by the formula.
  • options (object) –

    A JavaScript object with the following properties:

    • namespace (string) - A namespace prefix, placed before the formulaName to ensure that two formulas with the same name do not overwrite one another. Defaults to c.

      Note

      When being called from the App Composer, the namespace is always followed by two underscores.

    • 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”

Formulas can be declaratively accessed in the App Composer by prepending the namespace (followed by two underscores) to the formulaName like so:

nameSpace__formulaName(arg1, ... argN)

For example, to use this custom formula:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
skuid.formula.Formula (
  '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 App Composer.

If the namespace option were not specified, then c__APPEND_TEXT('text1', 'text2') would be used instead.