execute javascript when another field in table row has changed

  • 1
  • Question
  • Updated 2 years ago
  • Answered
  • (Edited)
Hello,

I am struggling to figure out how to make the if statements run each time the Status__c field is changed, is anyone able to help me with this? I'm sure it is something simple.

The snippet is on the Comments__c field in a table:


var $ = skuid.$;
var field = arguments[0],
    value = arguments[1],
    model = field.model,
    row = field.row;

if ( row.Status__c==="Not Applicable" ) {
    skuid.ui.fieldRenderers.TEXT.edit(field, value);
        if( value === null ){
            field.element.css({'border':'solid 2px #ff0000'});
        }
}
else if ( row.Status__c==="Completed" ) {
    skuid.ui.fieldRenderers.TEXT.readonly(field,value);
}
else {
    skuid.ui.fieldRenderers.TEXT.readonly(field,value);
}
Photo of William Keam

William Keam

  • 302 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Thimo

Thimo

  • 1,280 Points 1k badge 2x thumb
You could add a model action on "row updated, field value changed" to re-query the model that it re-renders the table.
Photo of William Keam

William Keam

  • 302 Points 250 badge 2x thumb
great! that works like a charm!

When Row in Model updated (Status__c) -> Adopt rows into Model from Model

Now I am looking to make the Comments__c field required when the Status is set to Not Applicable

edit: nevermind! a simple validation rule was perfect for this instance
(Edited)