Can a button affect the values in fields?

  • 4
  • Question
  • Updated 3 years ago
  • Answered
I have a picklist of a bunch of statuses (new, submitted, rejected, in progress, etc.), but ideally the user should only be able to choose one (submitted) or leave it alone (new, or approved). Is there a way to make a button on a Skuid page that changes the value in a field on that page to something specific (and then even saves the page, perhaps)? Then the user doesn't have to click on a field and then choose a value in the field, they can just click once.

Right now I'm contemplating adding a new picklist field that has only the two the values in it, then a workflow that can update the main status field once they save their changes, since there isn't a good way to limit which values the user can choose in a picklist field. Obviously that's hokey, though, and doesn't improve the UI experience, either.
Photo of Peter Bender

Peter Bender, Champion

  • 6,296 Points 5k badge 2x thumb

Posted 7 years ago

  • 4
Photo of Zach McElrath

Zach McElrath, Employee

  • 55,610 Points 50k badge 2x thumb
This is doable with a JavaScript Snippet. If your button (Page Title, Table Row/Global/Mass Action, Wizard, or unattached) is set to the type of "Custom", then you can specify the name of a Snippet to execute. Supposing that the Object you want to update is Case, and you have a Model called "CaseData", with one row in it, and you want to update the "Status" field to be a certain value, e.g. 'Escalated', and then want to immediately save that Model, here's what your snippet code would look like:

var CaseModel = skuid.model.getModel('CaseData');
var CaseRow = CaseModel.getFirstRow();
Photo of Peter Bender

Peter Bender, Champion

  • 6,296 Points 5k badge 2x thumb
Awesome - so easy! Every time you post a solution like this it gets me more excited to see a reference for the Skuid object model, so I can figure more of these things out myself, and come up with cool enhancements. Extrapolating from this will become very handy.
Photo of Kaede Holland

Kaede Holland

  • 3,176 Points 3k badge 2x thumb
This is cool, you guys!