snippet to execute each time UI field's value is changed (without saving)


Is it possible for an In-Line Js Snippet to execute each time a UI-Only field’s value is changed (without saving ofc, as Ui -only field won’t keep value…)

So each time Ui-Only field named : paid_percentage is changed for this inline-snippet to run

var params = arguments[0],   $ = skuid.$;var model = skuid.$M(‘FundingPerformance’);
var row = model.getFirstRow();
var dateVar = row.Effective_Balance_Date__c;
var daystoadd = row.days_to_add;
var newdate = row.Date_percentage_reached;
//convert from Salesforce date to Javascript date
var jsDate = skuid.time.parseSFDate(dateVar);
//add days
jsDate.setDate(jsDate.getDate() + daystoadd);
//convert from Javascript date back to Salesforce date
var daysAdded = skuid.time.getSFDate(jsDate);
model.updateRow(row,{Date_percentage_reached : daysAdded});


you’d create a custom renderer and add an onchange handler to the field.

Hi Dave

As Mordechai already wrote, a Custom Field Renderer is the way to go.

It should look something like this:

var field = arguments[0],    value = arguments[1],
    $ = skuid.$;
        inputType: ‘text’,
        value : field.row[],
        onChange : function( value ) {
        //Your Action here
       // To run your Snippet use 
       // skuid.snippet.getSnippet(‘SnipetName’)();
            console.log(“On Change Event”);

Make sure to change “TEXT” to whatever Type your UI Only Field is.

This would be an easier version of this code: 

var field = arguments[0], 

    value = arguments[1], 

    model = field.model, 

    row = field.row, 

$ = skuid.$; 


    //some actions after the value of the element has changed 



Thank you Chris, I just tried the easier version with added Action: skuid.snippet.getSnippet(‘SnipetName’)();

And it works like a Charm :slight_smile: