When a quote is contained in the data of a field being evaluated in a formula, various exception occur ranging from ILLEGAL TOKEN to unexpected string (depending on what the formula is doing). This leads to incorrect results in formula fields and more concerning, there is no indication that anything failed as it’s a caught exception and just carries on.
Beyond the basic sample demonstrated below, this problem really manifests itself with RTF fields.
Notes - This is a variation of another issue described at https://community.skuid.com/t/cr-lf-in-text-field-results-in-illegal-token-error-in-formu…
Steps to reproduce
- Create page using XML below
- Preview page
- Change account name to “Foo” (without the quotes)
Expected Behavior = Actual Behavior
Is Foo becomes TRUE
- Add a quote character to the end of the name
Expected Behavior
Is Foo is false and no exception is encountered
Actual Behavior
Is Foo is false but exception is encountered at the following location:
try { formulaResult = eval(initialMerges)
} catch (e) {
return $(document.body).one("pageload", function() {
skuid.component.getByType("skuidpage")i0].addProblem("Invalid syntax for field formula: " + template + ". " + e)
}),
null
}
Sample Page XML
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Account"> <models>
<model id="Account" limit="1" query="true" createrowifnonefound="false" sobject="Account" adapter="" type="">
<fields>
<field id="Name"/>
<field id="CreatedDate"/>
<field id="IsFoo" uionly="true" displaytype="FORMULA" label="IsFoo" readonly="true" returntype="BOOLEAN">
<formula>{{Name}}=="Foo"</formula>
</field>
</fields>
<conditions>
<condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
</conditions>
<actions/>
</model>
</models>
<components>
<pagetitle model="Account" uniqueid="sk-Xuyi0-70">
<maintitle>
<template>{{Name}}</template>
</maintitle>
<subtitle>
<template>{{Model.label}}</template>
</subtitle>
<actions>
<action type="savecancel" window="self"/>
</actions>
</pagetitle>
<basicfieldeditor showsavecancel="false" showheader="true" model="Account" mode="edit" uniqueid="sk-Xuyi0-71" buttonposition="">
<columns>
<column width="100%">
<sections>
<section title="Basics">
<fields>
<field id="Name"/>
<field id="IsFoo" valuehalign="" type=""/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
<resources>
<labels/>
<css/>
<javascript/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>