Javascript Exception: Cannot read property 'toLowerCase' of undefined on updateRow (Banzai 7.24)

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
As described in this related issue:
https://community.skuidify.com/skuid/topics/checkbox-ui-only-field-tolowercase-exception-on-cancel-c...
When using updateRow and inadvertently setting a Boolean field with an undefined value the following exception and stack trace occurs:
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined(...)o @ skuid__SkuidJS:27(anonymous function) @ skuid__SkuidJS:28o.extend.each @ skuid__JQuery:2(anonymous function) @ skuid__SkuidJS:28o.extend.each @ skuid__JQuery:2W.updateRows @ skuid__SkuidJS:28W.updateRow @ skuid__SkuidJS:28(anonymous function) @ VM2429:2InjectedScript._evaluateOn @ VM2423:875InjectedScript._evaluateAndWrap @ VM2423:808InjectedScript.evaluate @ VM2423:664
The issue occurs in the latest Banzai 7.24 but is handled without error in the only previous version of Skuid I have available to me 6.8.19. The following page xml and javascript should hopefully replicate the exception for diagnosis.
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="false" showheader="false">
   <models>
      <model id="contacts" limit="10" query="true" createrowifnonefound="false" adapter="" type="" sobject="Contact">
         <fields>
            <field id="HasOptedOutOfEmail"/>
            <field id="FirstName"/>
            <field id="DoNotCall"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
   </models>
   <components>
      <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="false" model="contacts" buttonposition="" mode="edit" uniqueid="sk-dmIvC-91">
         <fields>
            <field id="FirstName"/>
            <field id="HasOptedOutOfEmail" type="" valuehalign=""/>
            <field id="DoNotCall"/>
         </fields>
         <rowactions>
            <action type="edit"/>
            <action type="delete"/>
         </rowactions>
         <massactions usefirstitemasdefault="true">
            <action type="massupdate"/>
            <action type="massdelete"/>
         </massactions>
         <views>
            <view type="standard"/>
         </views>
      </skootable>
   </components>
   <resources>
      <labels/>
      <javascript/>
      <css/>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>
Run this code on the page above to trigger the exception:

skuid.$M("contacts").updateRow(skuid.$M("contacts").getFirstRow(),{"HasOptedOutOfEmail":undefined})
The easiest workaround I have is to check for undefined values and avoid setting them in the updateRow call.

Thanks to Barry and Ben for the support given in the related issue and hope that this is enough for a fix in the next release.
Photo of Stephen Chan

Stephen Chan

  • 956 Points 500 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Thanks for this bug report, Stephen. It will be fixed in our next patch release.
Photo of Stephen Chan

Stephen Chan

  • 956 Points 500 badge 2x thumb
Good stuff, glad to hear that it helped. Thanks for the responsive support as well.
(Edited)
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
This has been addressed in Banzai Update 6 - Patch 1 (7.27.1), now available from Skuid releases page.