Skip to main content

When a field on a custom template popup is marked as “required” (UI required, not SFDC required), the record is allowed to be saved without specifying a value in the field.


Steps to reproduce:


  1. Create new Account Detail page

  2. Add template field to field editor

  3. Set template to “{{BillingCity}}”

  4. Choose “Show custom popup”

  5. Change the “Billing City” field in the popup to required leaving all other default config

  6. Preview the page

  7. Go in to edit mode of the popup and make sure there is no value

  8. If “Save” isn’t enabled, make a change on Name field

  9. Save the record

Actual Result

Record is saved


Expected Result

Validation error for Required field BillingCity should be displayed


Sample Page XML


<skuidpage unsavedchangeswarning="yes" showsidebar="true" showheader="true" tabtooverride="Account">   <models>
<model id="Account" limit="1" query="true" createrowifnonefound="false" sobject="Account">
<fields>
<field id="Name"/>
<field id="CreatedDate"/>
<field id="BillingCity"/>
<field id="BillingCountry"/>
</fields>
<conditions>
<condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
</conditions>
<actions/>
</model>
</models>
<components>
<pagetitle model="Account">
<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="read" buttonposition="" layout="">
<columns>
<column width="100%">
<sections>
<section title="Basics" collapsible="no">
<fields>
<field id="Name" valuehalign="" type=""/>
<field type="COMBO" valuehalign="" editmodebehavior="custompopup">
<label>Billing City Template</label>
<template>{{BillingCity}}</template>
<editmodepopup title="Billing City Template" width="450">
<components>
<basicfieldeditor showsavecancel="false" mode="edit" model="Account">
<columns>
<column width="100%">
<sections>
<section title="">
<fields>
<field id="BillingCity" valuehalign="" type="" required="true"/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
</editmodepopup>
</field>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
</components>
<resources>
<labels/>
<css/>
<javascript/>
</resources>
</skuidpage>

Hi Barry,

I doubt we’ll be able to fix this issue any time soon.

In order to fix this, we’d have to add a lot of complexity to the read mode renderer for template fields. The validation actually works correctly when the popup is still up.  If you were to add a “save” hotkey, and use the hotkey while the popup was up, the validation would work as expected.  However, when the field is in read mode, none of the logic that would register required fields is run.  To add more complexity, conditionally unrendered fields are not added to required fields, so the read mode renderer would have to run conditional rendering logic on its custom popup as well to know which fields in the template were truly required.

I think the best way around this for now is to use the skuid.ui.List.addRequiredField() api.


Hey Ben -

This makes sense and I can see, given the way skuid detects “requiredness,” why this wouldn’t be an easy solution.  As you mention, it gets even more complex when factoring in conditional rendering within the popup itself.

I did some more thinking/testing and the same issue occurs on normal popups on a page and for the same reason that you describe above regarding templates.  In short, a field has to be rendered for Skuid to track is as required.  If the popup isn’t open, it’s not tracked as required.

Using the addRequiredField API will work.  Unfortunately, in the template case you can’t run a snippet to gain easy access to the list that the field itself is registered with.  In the case of a popup, the rendering wouldn’t occur until the popup is displayed so a renderer snippet wouldn’t be a viable solution there at a field level.

Any suggestions on the easiest way to call addRequiredField on the appropriate list?  I’m thinking of a couple of options in a document.ready.

1) Get the model, iterate registeredLists checking renderedItems.fields to make sure the field in question is even rendered and then invoke API.  
2) Get the Field Editor and call API on its list

In our particular case it gets slightly more complicated because depending on what the user has modified on the screen, requiredness is conditional so we need to call addRequiredFIeld and removeRequiredField as appropriate.  I can do the flip as needed in the framework that we’ve built on top of skuid because of all the event tracking which piggybacks on model events, etc.

Thanks!


You’ve just given me the info I was searching for. I also can share my experience in files merging. BTW, if anyone needs to merge PDF/PNG files online, I found a service here https://goo.gl/tds6cB.


Reply