Default Read/Edit Field Editor

Please direct me if this thread already exists, but it’s quite difficult to search for read/edit permissions when it can apply to anything.

For our Skuid Lead pages, we use two field editors. The first one is for when the the lead is Sales Accepted, Reached Out, or Engaged - the Default Mode for that is “Read with Inline-Edit”. The other field editor is for all other Lead statuses and the Default Mode is “Read-Only”. 

Will mentioned to me that Robb said it was possible to simply render this option using a custom JS snippet, so we would only need one field editor. It’s a bit of a pain to have two separate Field Editors to customize and keep identical, and I wonder if it’s also a drain on resources. 

How can I stick to working within one Field Editor, and then making it editable as a whole or not based on the Lead Status?


Here is a thread about doing just this for the Table component.

Making this work for the field editor would involve trivial changes. 

For those changes, I’m going to take a quick stab at what they might be.

row -> field
getFirstRow() -> ?? is there a getField function or similar?
row.your_field_name -> field.your_field_name
$(‘.nx-skootable:visible’).data(‘object’) -> ??
table.mode -> model.mode or editor.mode?

Not sure I see anything else that would need to be changed at an initial glance.

I’m mostly just in the dark here, trying to feel it out using the API References.

Ok.  Let’s step back here and comment up the code to help you out. 

But, first.  Go to your field editor and look in the advanced tab.  Add a name to the “class” property.  I used MagicForm   

Then create a javascript resource of type Inline:

Here is the code:   (you can delete the commentary that begins with // )

var $ = skuid.$; $(function() { var m = skuid.model.getModel('your_model_name'); //Keep the quotes var renderFieldEditor = function() { //Change here is just a Var name not essential. var row = m.getFirstRow(); //Gets the first row of data from your model. Not about the Table. var fieldToCheck = row.your_field_name; // Probably LeadStatus - use the API name var fieldEditor = $('.MagicForm').data('object'); //Call the Field Editor we added the class property to above //In this section we evaluate the lead status if(fieldToCheck == 'Sales Accepted' || fieldToCheck == 'Reached Out' || fieldToCheck == 'Engaged ' ) { fieldEditor.mode = 'read'; fieldEditor.list.render({doNotCache:true}); } else { fieldEditor.mode = 'readonly'; fieldEditor.list.render({doNotCache:true}); } }; // run the first time (page load) renderFieldEditor(); // set to listen for changes, then rerender field editor // comment out this code if you only want to check on page load var listener = new skuid.ui.Editor(); listener.handleChange = function() { renderFieldEditor(); }; listener.registerModel(m); });

Note: that last section where you listen for changes may be too much.  It takes effect immediately, even without saving the record.  Might be too much. 

Is the mode “read” the equivalent to Read with Inline-Edit? And I assume the default mode doesn’t matter if the code is working properly (since they would override it for any situation).

Ha - I had selected In-line (snippet) rather than In-line. Is there documentation somewhere that explains the “Resource Location” picklist?

But it works now, thanks per usual Rob!

Here is a good conversation on the difference between resource location types:…