Brooklyn: Conditionally un-rendered required field causing error on save

I am testing Brooklyn in a sandbox. I have a popup where I create a new task record. I have a required field that is conditionally rendered only if a check box is checked. That checkbox is not checked, but the required field is still rendering. As a consequence, I can’t save the record without completing that field.

Hi Raymond,

Can I assume that this was working prior to Brooklyn being installed, or is this a problem that presented itself when you created it after installation?

If the checkbox is a UI-only field I may have experienced something similar. It may seem like a silly test, but have you tried exposing the field in your popup and switching it on and off to confirm whether it renders the required field in or out upon further prompting? Turned out in our case that despite creating the checkbox field, we hadn’t actually instantiated its value anywhere. We had to use a field update action prior to the popup launching to make sure the checkbox gained a non-undefined value. Sorry if I’m barking completely up the wrong tree!

Sometimes you have to bark up a lot of trees to find the right one. In this case, I use that page in my production environment which I did not upgrade to Brooklyn. It works in production. The same page when in my sandbox which I did upgrade to Brooklyn has the issue. Thanks for your reply, though.

Hello Raymond,

I have a few questions to drill down a bit more. First, is your conditionally-rendered field set as “required” from within Salesforce, or is it set as “required” via Skuid’s own field settings? Second, is the checkbox you’re using a ui-only field, or is it from Salesforce? 

Also, if you’re able to share screenshots of both pre- and post-Brooklyn update so we can see a bit more detail of what you’re experiencing, that would be helpful too.

Mark

Both fields are salesforce custom fields on the activities/task standard object. “Recurrence interval” determines how many days between repeating tasks. If the “repeat this task” custom checkbox field is checked, then the recurrence interval number field becomes rendered and is required by Skuid, not Salesforce. I don’t have screenshots handy. I’ll try to get them tomorrow, but they are unremarkable. The recurrence interval field is hidden in both When repeat task checkbox is unchecked, but upon model save an error indicating that a required field has not been completed pops up in Brooklyn.

If custom fields are set up in Salesforce to be required, saving the record without data in that field would throw an error even if the required field wasn’t being rendered. Does your page have a way of making sure there’s good data in the required field?

They are not required at Salesforce level. Only Skuid level. This page works fine in Rockaway.

Using Brooklyn Iteration 1.1 and conditionally rendering a required (by Skuid) field only if a checkbox was checked, I wasn’t able to reproduce the issue you’re describing. In other words, in my test page, the field was only treated as required if it was being rendered, and an error message only came up when the required field was rendered and blank.

Are you working off of iteration 1.1? 
Also, is the custom checkbox field something you can check/uncheck on your page, on the fly, to see the required field ‘un-render?’ If so, does the error still come up after the checkbox is unchecked?

I may have a similar problem, that I first attempted to explain in my thread about my Search Component locking up.

https://community.skuid.com/t/search-component-locked-up-with-unsaved-model-changes

I’ve done a lot more testing around this problem, and found it is also related to required fields that are conditionally being shown.  Ours are UI fields and only required on the Skuid side, not Salesforce side.

Our application is a CPQ (quoting tool) and the search component is used to search for products and then the user configures them (gives additional required information) and then adds them to the quote.

For example:

User picks “Pack of Paper” from the search component, which searches the Product object.  We pass the ID of the product to a new model called ‘selectedProduct’, set the ID condition and then query that model so we can get more information on it.  Because this is product type “Paper” (field render condition show when selectedProduct model, field ProductType__c = “Paper”,) we show a UI fields that says “How many sheets?” and the user must pick the number of sheets before adding the item to the quote. (we manipulate the pricing and/or part number based on the user’s selection.)

Then user then picks “Extension Cord” from the search component. Passes the ID to the selected Product Model and requeries the model (completely replace). This is now product type “Cords” so the “How Many Sheets” UI field should disappear via conditional rendering, and instead “Cord Length” shows up - also a required field.

The problem is that the user is unable to select Extension Cord from the search component. It becomes unresponsive to the select action (searches just fine… just won’t do anything when you select a product) and the console says ‘uncaught exception: Model ‘selectedProduct’ has unsaved changes. To update this model’s data, you must first save or cancel the changes’.

We have tried adding a “Cancel Model” action to the search component as the first select action and that didn’t work.

When I make my UI field “How many Sheets” NOT required, then the extension cord is able to be selected.  We must have the field required for our application, so this isn’t a long term fix.  But narrowing it down to the required field that is no longer rendered made me think it might be related to this problem.

We’ve been building this CPQ system for almost a year, and this week was our CRP testing, and we’ve run into quite a few snags like this.  We’d love some help!

Update: Added a remove rows from model action as the first item in my Select item from the search component, and that cleared the problem for me.  Not ideal (and it used to work pre-Brooklyn) so hopefully this will help someone else.  :)