Question

log.original_fields is always null. why?

var updateChangeLog = function(log, currentRecord) {
   var records, record;
   if(!log.original_fields) {
      records = ["a","b"];
      log["original_fields"] = records;   
      // log.original_fields = records; // doesnt work either
      debugger;
   }
}
Was it helpful?

Solution

I don't thin it's good practice to modify an object the function recieves as a param, at least without then returning the object. Better way would be make the function a method of the log object.

like logObject.updateChangeLog(currentRecord);

the updateChangeLog would containt ... if(!self.original_fields) self.original_fields = records; ... but remember to initialize the logObject original_fields to false or nil.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top