This can’t be an official problem since it’s an undocumented api method (this might even be intended functionality), but here it is anyway.
Whichever formula was last registered on the page will be returned by
skuid.formula.getFunction
,no matter what you put as the parameter (even nothing).
reproduction page below. Just press the register buttons and you’ll see that whichever register button you press last is called (open the console to see) when you press either call button.
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true"> <models>
<model id="modelrequiredforbuttons" query="true" createrowifnonefound="false" datasource="Ui-Only" processonclient="true">
<fields/>
<conditions/>
<actions/>
</model>
</models>
<components>
<grid uniqueid="sk-3Pn2xm-295">
<divisions>
<division behavior="flex" minwidth="100px" ratio="1">
<components>
<wrapper uniqueid="sk-3PocMT-112">
<components>
<template multiple="false" uniqueid="sk-3Pn60X-308">
<contents>Register Formulas</contents>
</template>
<buttonset uniqueid="sk-3Pn4Zw-302" model="modelrequiredforbuttons">
<buttons>
<button type="multi" label="Register Formula 1">
<actions>
<action type="custom" snippet="addformula1snippet"/>
</actions>
</button>
<button type="multi" label="Register Formula 2">
<actions>
<action type="custom" snippet="addformula2snippet"/>
</actions>
</button>
</buttons>
</buttonset>
</components>
<styles>
<styleitem type="background"/>
<styleitem type="border" borders="all" padding="all" margin="all">
<styles>
<styleitem property="border" value="5px solid blue"/>
<styleitem property="padding" value="5px"/>
<styleitem property="margin" value="5px"/>
<styleitem property="box-sizing" value="border-box"/>
</styles>
</styleitem>
<styleitem type="size"/>
</styles>
</wrapper>
</components>
</division>
<division behavior="flex" verticalalign="top" minwidth="100px" ratio="1">
<components>
<wrapper uniqueid="sk-3Pof_t-131">
<components>
<template multiple="false" uniqueid="sk-3Pn6W5-312">
<contents>Call Formulas</contents>
</template>
<buttonset uniqueid="sk-3Pn56_-305" model="modelrequiredforbuttons">
<buttons>
<button type="multi" label="Call Formula 1">
<actions>
<action type="custom" snippet="callformula1"/>
</actions>
</button>
<button type="multi" label="Call Formula 2">
<actions>
<action type="custom" snippet="callformula2"/>
</actions>
</button>
</buttons>
</buttonset>
</components>
<styles>
<styleitem type="background"/>
<styleitem type="border" borders="all" margin="all" padding="all">
<styles>
<styleitem property="border" value="5px solid blue"/>
<styleitem property="padding" value="5px"/>
<styleitem property="margin" value="5px"/>
<styleitem property="box-sizing" value="border-box"/>
</styles>
</styleitem>
<styleitem type="size"/>
</styles>
</wrapper>
</components>
</division>
</divisions>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</grid>
</components>
<resources>
<labels/>
<javascript>
<jsitem location="inlinesnippet" name="addformula1snippet" cachelocation="false">formulaName = 'formula1';
formulaFunction = function(){
console.log('formula1 has been called');
};
options = {numArgs : 0,returnType : 'string'};
skuid.formula.Formula(formulaName, formulaFunction, options);
</jsitem>
<jsitem location="inlinesnippet" name="addformula2snippet" cachelocation="false">formulaName = 'formula2';
formulaFunction = function(){
console.log('formula2 has been called');
};
options = {numArgs : 0,returnType : 'string'};
skuid.formula.Formula(formulaName, formulaFunction, options);
</jsitem>
<jsitem location="inlinesnippet" name="callformula1" cachelocation="false">skuid.formula.getFunction('formula1')();</jsitem>
<jsitem location="inlinesnippet" name="callformula2" cachelocation="false">skuid.formula.getFunction('formula2')();</jsitem>
</javascript>
<css/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>