Model hasChanges immediately after cancel changes due to required picklist

  • 2
  • Problem
  • Updated 2 years ago
  • In Progress
When a picklist in a field editor is marked to "required" and "none" is not allowed, after cancelling changes in the model, the model immediately has changes again because a value is getting re-established on the field when the original value of the record is null/empty.

This manifests itself when the model is marked to "prevent users from leaving page".  When you click a "Cancel" button, then cancel changes and navigate away, the "model has changes" message appears because even though the model changes were cancelled, the picklist field was immediately changed again.

Not sure how to really work around or solve for this one due to the way model data is processed by components, etc.

Steps to Reproduce:
1) Locate a contact in the org and ensure the "Salutation" field is empty/blank
2) Create page using XML below
3) Preview page using contact from #1
4) Click "Cancel & Go"

Sample Page XML
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Contact">   <models>
      <model id="Contact" limit="1" query="true" createrowifnonefound="false" sobject="Contact" adapter="" type="" doclone="">
         <fields>
            <field id="FirstName"/>
            <field id="LastName"/>
            <field id="CreatedDate"/>
            <field id="Salutation"/>
         </fields>
         <conditions>
            <condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
         </conditions>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="Contact" uniqueid="sk-FkT5s-71">
         <maintitle>
            <template>{{FirstName}} {{LastName}}</template>
         </maintitle>
         <subtitle>
            <template>{{Model.label}}</template>
         </subtitle>
         <actions>
            <action type="multi" label="Cancel &amp; Go" icon="sk-icon-cancel">
               <actions>
                  <action type="cancel">
                     <models>
                        <model>Contact</model>
                     </models>
                  </action>
                  <action type="redirect" window="self" url="http://www.skuidify.com"/>;
               </actions>
            </action>
         </actions>
      </pagetitle>
      <basicfieldeditor showsavecancel="false" showheader="true" model="Contact" mode="edit" uniqueid="sk-FkT5t-72" buttonposition="">
         <columns>
            <column width="50%">
               <sections>
                  <section title="Basics">
                     <fields>
                        <field id="FirstName"/>
                        <field id="LastName"/>
                        <field id="Salutation" valuehalign="" type="" required="true"/>
                     </fields>
                  </section>
               </sections>
            </column>
            <column width="50%">
               <sections>
                  <section title="System Info">
                     <fields>
                        <field id="CreatedDate"/>
                     </fields>
                  </section>
               </sections>
            </column>
         </columns>
      </basicfieldeditor>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript/>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Karen Waldschmitt

Karen Waldschmitt, Official Rep

  • 8,220 Points 5k badge 2x thumb
Hi Barry~

I am unable to reproduce the error you are describing. When I look for a contact that doesn't have a salutation picked, for example this one:

When I create a page using your XML and preview it for the same person, this is what I see before I edit anything: 

Because you are making salutation required on the page and "None" is not permitted, the salutation field should automatically pick the first value in the picklist. In this case, there ARE unsaved changes on the page since the salutation is now Mr. instead of null. However, when I click Cancel & Go, it takes me to the URL you have in the redirect and is NOT showing an error and the contact record is remaining as it was before ... Is the problem that I am able to navigate away even though we checked to "Prevent users from leaving the page if the model has unsaved changes?"

Can you clarify what are you expecting to happen and what is actually happening? I am getting confused by this statement since I don't see it happening: "When you click a "Cancel" button, then cancel changes and navigate away, the "model has changes" message appears because even though the model changes were cancelled, the picklist field was immediately changed again."

Thanks!
Karen
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Sorry Karen, I forgot to include expected/actual behavior in my OP.

Agreed on everything you've said regarding how the data behaves.  However, when I click "Cancel & Go", I get the "You have unsaved changed alert" even though "cancel changes" was just run on the model.

The reason for this makes perfect sense since the Field Editor field is marked to "None" not permitted.  That said, from a user perspective, they didn't make any changes so when the alert pops saying there are "unsaved changes" it's confusing to a user.  Since they technically didn't make a change, I'm looking for a solution on how to avoid this while still marking the field editor to "not allow none."

It comes down to the way Skuid handles the cancel changes event within the registeredLists/Items, etc.  Before the Redirect occurs, the field editor resets the field to "Mr" because none is not allowed.  Unfortunately, this immediately triggers a change which causes redirect to display the alert.

Sorry again for not providing these details originally.  Here's what I should have included

Expected Behavior
Page redirects to target url without "you have unsaved changes" alert displaying

Actual Behavior
"unsaved changes" alert displays and then page redirects (assuming user picks Leave this page

In short, the way Skuid handles change events within the registeredLists/Items/etc. is causing a change to model data when the intention of the actions are to cancel everything and leave.  So the question/issue is how to avoid this.

Hope this helps.  Thank you!
Photo of Karen Waldschmitt

Karen Waldschmitt, Official Rep

  • 8,220 Points 5k badge 2x thumb
Barry~

What version of Skuid are you seeing this occur in?

Thanks!
Karen
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Yeah, I like "Save and Navigate" and "Cancel and Navigate". I'll see what the team thinks.
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Good deal, thanks!
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Hey Ben - Any updates on how this might be addressed after discussing with team?
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Hey Ben - Any updates on how this might be addressed after discussing with team?
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Hey Ben -

Another scenario that might be suffering from this issue (cancel changes doesn't really cancel changes) was brought up in the post at https://community.skuid.com/skuid/topics/bug-with-after-close-actions-feature?topic-reply-list%5Bset....

Any updates from on how/when this might be addressed?
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Skuid Team - Any insight on this?