Button Enable when Snippet Returns True

Hi Peter, thanks for the response.

  1. I am on Skuid 8.15.9
  2. Yes, it is an In-Line (snippet) type. To trigger the snippet to run, I have a model action that looks for my field “Description” to be updated and then it runs the snippet. It appears as though the snippet is running based on me seeing the “check results true” in the console window.
  3. I just cleared my cache and tried again - still didn’t work. (Chrome)
  4. Yes, enabling conditions are set to ALL must be true, and the snippet is the only condition for enabling.


For fun, I tried a few more things:

  1. Tried in Firefox. Console returned “check result true” but the button did not enable
  2. Put a new page title and button, called My New Button on the page and used the exact same rendering condition. On page load, this button was enabled but the original Save button still was not. They both are using the same snippet. Weird.

It appears as thought I don’t fully understand the behavior as well. I am using the enable snippet to check to make sure required fields are not null before the user can attempt to save. Because this create page is used for a couple “types” of records, the fields that required depends on the type.

For example, if you create new record of Type A, then you must fill out ‘Description’ and ‘Length’.
If you create a new record of Type B, then you must fill out ‘Description’ and ‘Weight.’

That is why I am using a snippet, to conditionally check the fields required based on the Type that the user has specified. Yes, we use required fields (red boxes) but sometimes they miss those fields, so we want the button disabled until they have satisfied the requirements, rather than get a messy error message.

So in my case, I had the Snippet Evaluates to True checking the fields. I had a model action set to run the snippet when these fields were updated on the row (so when the user updates Description, run the snippet to see if the conditions were now satisfied. If true, then then button should enable.)

With the “My New Button” case above, the button was enabled on page load - using the simple “return True” snippet. I didn’t expect this, because I didn’t think the In-Line (snippet) would run on page load, I thought I would need to trigger it. I just want to make sure I understand how the enable snippets work, and what the event is that makes the snippet evaulate the conditions.

My full snippet is below. I commented out all the logic and just entered the simple return true for my testing - but still don’t even have that working on my save button.

var params = arguments[0], $ = skuid.$;

/*
var NcmirModel = skuid.model.getModel(‘AFLCase’);
var NcmirRow = NcmirModel.getFirstRow();

var type = NcmirModel.getFieldValue(NcmirRow, ‘Type__c’);
var issueProcess = NcmirModel.getFieldValue(NcmirRow, ‘Issuing_Department__c’);
var issueMachine = NcmirModel.getFieldValue(NcmirRow, ‘Issuing_Machine__c’);
var defectCat = NcmirModel.getFieldValue(NcmirRow, ‘Defect_Category__c’);
var defectDetail = NcmirModel.getFieldValue(NcmirRow, ‘Defect_Detail__c’);
var currentLength = NcmirModel.getFieldValue(NcmirRow, ‘Current_Cable_Length__c’);
var transactMRB = NcmirModel.getFieldValue(NcmirRow, ‘Transacted_to_MRB__c’);
var description = NcmirModel.getFieldValue(NcmirRow, ‘Description__c’);

// Check Discrete Job required fields
var enableCheck = false;

if (type == ‘Discrete Job’){
alert(‘discrete job’);
if (
(issueProcess !== “”) &&
(issueMachine !== “”) &&
(defectCat !== “”) &&
(currentLength !== “”) &&
(description !== “”)
){
enableCheck = true;
console.log('check result ’ + enableCheck);
}
// else {
//enableCheck = false;
// }
}

return enableCheck;

*/
var enableCheck = true;
console.log('check result ’ + enableCheck);
return enableCheck;