Catch original form value for comparing to submitted value

From a Form, I need to catch a particular field value BEFORE the form is submitted so that I can compare it to the submitted value and do something with the difference (ie original value was 20, new value is 15, I am going to do something with 5).

I can do the After, but not the Before.

I am listening on the view render, but there is no record yet for me to grab. Am I listening to the wrong thing? This is a single record form, not a inline-editable table.

$(document).on('knack-view-render.view_336', function(event, view, data) {
    
    //Pausing to let the records load doesn't help
    
    var MyOriginalPortion = record["field_100"];           // THIS LINE DOES NOT WORK
    console.log(MyOriginalPortion);
        
    $(document).on('knack-form-submit.view_336', function(event, view, record) {    
      
            var PaymentRecordID = record.id;
            var ThisActivityID = record["field_199"];           // ActivityID field in Payments Table 
            
            var MyNewPortion = record["field_100"];           // THIS LINE WORKS FINE
            console.log("Mew Portion: " + MyNewPortion);

// bla bla bla
            

Use the ‘data’ variable returned inside your view render (not ‘record’).
var MyOriginalPortion = data.field_100;

1 Like

Yep that was what I needed! Thanks!