Issue with getting tablefield's value

Hi all, I am in the doctype Salary structure and i want to get the total sum for a table in New Salary Structure, do i point the script to “Salary Structure” or “New Salary Structure”?

frappe.ui.form.on(“Salary Structure”, “amount”, function(frm, cdt, cdn) {
var totEarnings = frm.doc.earnings;
var total = 0
for(var i in totEarnings) {
total = total + totEarnings[i].amount;