Skip to main content

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


  1. Create page using XML below

  2. Preview page

  3. Change account name to “Foo” (without the quotes)

Expected Behavior = Actual Behavior

Is Foo becomes TRUE


  1. 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>

Barry,

I actually noticed this while I was verifying the issue with formula fields containing new line characters. I logged it at the time and planned to double back to it. The fix should be similar to what we did for the new line issue, so I think we can probably turn it around pretty quickly. We’ll keep this thread updated once we have something more specific. Thanks!


Thanks for the update J.  

This, along with the CRLF issue, is rendering (no pun intended) a large portion of our app completely useless right now.  I came up with a workaround to the CRLF issue (overriding window.eval, tokenizing, then passing through, then untokenizing) but unfortunately, there isn’t a way for me to workaround the quote issue as by the time the code path hits a public method, I don’t have access to just the field value.  It’s buried deep inside of getMergeResult.

Any idea when you’d be doubling back to this?


I’d bet on the initial release of Rockaway, maybe even the same release that contains the CRLF fix since the approach should be pretty similar (same story, different offending literals), but I can’t say for sure. Does that help?


Thanks J.  Yeah for sure, any insight is helpful (understanding not guaranteed).  I’ve got to decide whether or not to pull a major feature I’ve built or wait.  Pulling it really isn’t an option so I’d have to redesign/recode,etc. which I really would like to avoid as it’s pretty core to the entire application.  We just added some RTF fields (which we need and can’t remove) and that is what exposed this issue.

Thanks again!


This fix is now available from Get the Latest Skuid Releases & Everything That Came Before in the Rockaway Release.


Tested and confirmed with Skuid 8.8.  Thank you!

Would still like to see the following block of code improved so that formula evaluations during runtime (after page load) are somehow made visible to the user or at least the console.


return $(document&#46;body)&#46;one("pageload", function() {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; skuid&#46;component&#46;getByType("skuidpage"))0]&#46;addProblem("Invalid syntax for field formula: " + template + "&#46; " + e) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<br />

Reply