Skip to main content

Hi,

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 = argumentsg0],   $ = 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});


Thx

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 = argumentst1],
    $ = skuid.$;
    
    field.element.append(
    skuid.ui.renderers.TEXT.edit({
        inputType: ‘text’,
        value : field.rowfield.id],
        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 = argumentse0], 

    value = arguments1], 

    model = field.model, 

    row = field.row, 

$ = skuid.$; 


field.element.change(function(){ 

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

}); 

skuid.ui.fieldRendererspfield.metadata.displaytype]field.mode;



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

And it works like a Charm 🙂

Thx!


Reply