Actions button bypasses required fields

I have a Button with multiple actions and when the page has no changes detected the button still saves and continues through all the actions even though the first action is Save Model(s) with the Roll Back entire save on any error checked. The next actions need to not run, which completes the section flag.

I am trying to have a complete button that validates all required fields entered, then updates a completed flag on the model.

Ideas on making this behave correctly or rendering a button only if all required fields are entered?

I have also tried something like this to validate the page with JS snippet in an Action but I am not getting any messages back?

var $ = skuid.$;var pageTitle = $(’#ROSPTitle’);
var editor =‘object’).editor;
var messages = [];
var models = [
       var listMessages = list.validateRequiredFields();
       if(listMessages && listMessages.length) {
// If we have warning messages, do NOT proceed
if (messages.length) {
    // Have our step’s editor handle the messages
    return false;

A simple resolution to this may be to run the Javascript snippet below before the Save action.

It seems like that the issue here is that it doesn’t even attempt a save if there are no changes and just continues with the rest of the actions, so all you need to do is add a snippet that validates that there are changes and the rest of the save validation you can leave up to Skuid.

var model =&nbsp;skuid.$M("YourModel");<br>//If no changes were made<br>if(skuid.$.isEmptyObject(model.changes))<br>{<br>//you can do an action here, or you can add an on error action to the snippet //don't continue and save<br>return false;<br>}

I think this is close. If they save their changes and then come back later to complete the page then this would block them since no changes would have been made. I need a combo of this and a way to check if the current page has any uncompleted required fields.

If that’s the case I would go with your original code, but because validateRequiredFields() only validates fields that have changed I would mimic the skuid error.


&nbsp;var listMessages = list.validateRequiredFields();<br>&nbsp; &nbsp; &nbsp; &nbsp;if(listMessages &amp;&amp; listMessages.length) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$.each(listMessages,function(){<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; messages.push(this);&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;});<br>&nbsp; &nbsp; &nbsp; &nbsp;}

with this 

$.each(list.requiredFields, function(k, requiredField) {&nbsp; &nbsp; if (![0].hasOwnProperty( ||[0][] === null&nbsp;||[0][] === '') &nbsp; &nbsp; &nbsp; messages.push(mimicSkuidError(requiredField.label)); });

and add this function

<br>function mimicSkuidError(fieldLabel){<br> return {<br>&nbsp; &nbsp; &nbsp; fields : [fieldLabel],<br>&nbsp; &nbsp; &nbsp; message : "Required Fields have no Value [" + &nbsp;fieldLabel + "]",<br>&nbsp; &nbsp; &nbsp; severity : "ERROR",<br>&nbsp; &nbsp; &nbsp; status : "REQUIRED_FIELD_MISSING"<br>&nbsp; &nbsp; }<br>}

How about this then. 

1. Update the field Completed to True
2. Save the Model
  b) On Error action to update the field Completed to False

This is assuming that you have no other actions that you’d like to not have run after the Save Model action.
This is also assuming the button is meant to save changes to the model.

What is the intended purpose of the button. Video would be helpful to get the context of what you are trying to achieve.