Update multiple records with a checkbox - Please help!

Hi,

I have been trying to use the code in this excellent example:

Update multiple records with a checkbox

http://helpdesk.knackhq.com/support/discussions/topics/5000039996

Instead of updating checked records though, I am trying to insert a new record into another object using the data fields in the checked rows. I have managed to get it right - the thing I'm struggling with is retrieving data values from the checked table row.

I have copied my code below. The part that adds the checkboxes to the table is not included, as this works fine (unless I'm missing something). Any help will be greatly appreciated...

Thanks

(All the code that is commented out are things that I've tried)

var insertRecords = function(id, record_ids) {
    var BuyerName = Knack.models['view_576'].toJSON().field_430_raw;

// alert (BuyerName);

// var Testing = id;
// var Testing = Knack.models[‘view_581’].toJSON().field_288_raw;
// var Testing = id.field_288_raw;
// alert (Testing);

// var data_view_581 = Knack.models[‘view_581’].data.toJSON();

	var data = {

// field_767: data_view_581.field_288_raw,
// field_741: record_ids.field_283,
// field_751: record_ids.field_276,
// field_751: [record_ids.id],

      	field_767: Testing,
  		field_763: BuyerName,   
	};

$.ajax({
url: ‘https://api.knackhq.com/v1/objects/object_32/records’,// + id,
type: ‘POST’,
/***** CHANGE TO YOUR OWN APPID AND API KEY HERE *****/
headers: {‘X-Knack-Application-ID’: ‘578773182826ba663f18618d’, ‘X-Knack-REST-API-Key’: ‘4c515280-4a17-11e6-bfd3-6989fe28c9de’},
data: data,
success: function(response) {
if ( record_ids.length ) {
// Every time a call is made, the array is shifted by 1.
// If the array still has a length, re-run updateRecords()

    insertRecords(record_ids.shift(), record_ids);
     
  } else {            
    // We know all records are processed when length = 0
    alert('Update complete!');
    Knack.hideSpinner();
  }
}

})
}

/**** CHANGE VIEW_ID TO YOUR OWN VIEW ID ****/
$(document).on(‘knack-view-render.view_581’, function (event, view) {

// Add an update button
$(’<button id=“update”">Update</button>’).insertAfter("#knack-body");

// Add checkboxes to our table
addCheckboxes(view);

// Click event for the update button
$(’#update’).click(function () {

// We need an array of record IDs
var record_ids = [];
  
// Populate the record IDs using all checked rows
$('#' + view.key + ' tbody input[type=checkbox]:checked').each(function() {
  record_ids.push($(this).closest('tr').attr('id')); // record id
});
   
Knack.showSpinner();

// Use the first ID in the array, then pass in the rest of the array
insertRecords(record_ids.shift(), record_ids);

$('#update').remove();

})
});

Dagmar - I've repsonded to this in the other thread here http://helpdesk.knackhq.com/support/discussions/topics/5000074007

Hope that helps.