Custom Formula Functions - How to use?

Formula and Function Reference — Skuid v13.0.10 Documentation

I’m attempting to use the default custom formula function, but it’s unclear how to even after reading the documentation. What is the Namespace? The snippet name? The Skuid page?

@Pat_Vachon deleted my responce as this is a troll i assume, given your 5 years on this community.

thanks for wasting my time thinking i was responding to a genuine question.

Absolutely not wasting your time. I would only post here if it were a question I don’t have the answer to. I’ve figured out how to use the default, but how is it that “C” is the namespace for this snippet? Where was “C” defined?

const utils = skuid.utils;

const {

DISPLAY_TYPES: {

    NUMBER,

    STRING,

}

} = skuid.constants;

// Register a new formula function named C__REPEAT for use in the runtime

new skuid.formula.FormulaFunction(

"REPEAT",

function( stringToRepeat, count ) {

    if (!utils.isString(stringToRepeat) || !utils.isNumber(count)) {

        return "";

    }

    return stringToRepeat.repeat(count);

},

// Optional metadata:

{

    description: "Creates a new string which repeats `stringToRepeat` the number of times specified by `count`",

    arguments: [{

        name: "stringToRepeat",

        type: STRING,

    },{

        name: "count",

        type: NUMBER,

    }],

    returnType: STRING,

}

);

Hey Pat,

What you’ve linked is more so meant as a reference for using custom formula functions instead of the details behind how they are built. Some builders may not know how the formula function’s JavaScript is written, but do know its name.

I think you’ll find what you’re looking for in the API reference for skuid.formula.FormulaFunction.

  • To answer your specific questions:

    Namespaces are just prefixes primarily meant to prevent custom formula functions from colliding with Skuid’s own out-of-the-box functions.

The namespace is defined in the options.namespace parameter of the formula function. However, this is an optional parameter—and if one is not defined then it defaults to

  • c

I hope this helps!