How to update a formula-based field if one of the input variable fields is edited

var updateAmountField = function(){
    // The row we want to update
    var opportunityRow = opportunityModel.getFirstRow();
    var totalAmount = 0;
    var domainRecords = skuid.model.getModel(‘Domains’).getRows();

    skuid.$.each(domainRecords,function(i,row){
       if (row.Sales_Price__c) totalAmount += row.Sales_Price__c;
    });

    console.log('new total: ’ + totalAmount);
    // Update the opportunity row
    opportunityModel.updateRow(opportunityRow,‘Reach_Price__c’,totalAmount);

   };

Hi there, 

I’m trying to do something similar, but with a Date/Time field instead of a Number.  I’ve modified the code above, but when I edit my primary field - “Nurse Intake Time - Patient Time Zone” - I don’t see a change in the formula field where this custom renderer is applied. 


var FIELDS_TO_LISTEN_ON = [‘Nurse_Intake_Time_Patient_Time_Zone__c’];
var field = arguments[0],
     value = arguments[1],
     row = field.row,
     listener;

skuid.ui.fieldRenderers.DATETIMEfield.mode;

// Register a listener so that if any of FIELDS_TO_LISTEN_ON are updated,
// then we will update ourself as well.

if (!listener) {
   
   listener = new skuid.ui.Field(row,field.model,null,{register:false});

   var calcNewValue = function(){

       var  value0 = row.Nurse_Intake_Time_Patient_Time_Zone__c || 0,
              value1 = skuid.time.parseSFDateTime(value0),
              value2 = row.Nurse_Assignment__r.UTC_Offset__c || 0,
              value3 = row.Account.tz__UTF_Offset__c || 0,        
        
        newValue0 = value1 + (value2/24 - value3/24);
        newValue=skuid.time.getSFDateTime(newValue0);
       
       field.model.updateRow(row,‘Nurse_Intake_Time_Patient_Time_Zone__c’,newValue);

       field.element.empty();
       skuid.ui.fieldRenderers.DATETIME.readonly(field,newValue);
       
   }
   
    listener.handleChange = function(){calcNewValue (); };
    listener.render = function() {};

   skuid.$.each(FIELDS_TO_LISTEN_ON,function(i,fieldToRegisterOn){
       field.model.registerField(listener,fieldToRegisterOn);
   });

   setTimeout(function(){
       // If there is already a changes row for this item,
       // then run calculation
       if (field.model.changes[field.row.Id]) {
             calcNewValue ();
       }
   },100);

}