Update connection records

Hi,

I have a Customer Object (object_1) where the Display Field is field_1

I have used the bellow code based on other contributions to copy all the customer records into another object (Customer Group)

The problem is that the connection record will not update, can someone tell me what I am missing? I can see that all other elements within each record are updated but not the connection...

$(document).on('knack-record-create.view_94', function(event, view, record) {


Knack.showSpinner();


var KnackAppID = "xxx"

var KnackAPIKey = "xxx"

//Get Customer

$.ajax({url: 'https://api.knackhq.com/v1/objects/object_1/records', type: "GET",

headers: {"X-Knack-Application-Id": KnackAppID, "X-Knack-REST-API-Key":KnackAPIKey},

success: function(data) { //alert('Records Retrieved!' + data.total_records);


//Loop through data, build newdata and insert new record into Customer Group

for (var i = 0; i < data.total_records; i++) {//alert(data.records[i].field_25);

var newdata = {

field_99: i + 1,

field_102: data.records[i].field_25_raw,

field_104: data.records[i].field_1_raw.id,

field_97: record.field_97,

field_101: record.field_101_raw[0].id

}


//Add data to CustomerGroup

$.ajax({

url: "https://api.knackhq.com/v1/objects/object_15/records/",

type: "POST",

headers: {'X-Knack-Application-Id': 'xxxx', 'X-Knack-REST-API-Key':'xxx'},

data: newdata,

//success: function(response) {alert('Records Added!');}

});

}

Knack.hideSpinner();

}

});

});

Thank you!

found the solution (see bellow) with the help of some good people in these forums . The secret sauce is in the

cust_conn

variable :)

$(document).on('knack-record-create.view_125', function(event, view, record) {

Knack.showSpinner();

var KnackAppID = "xxxx"
var KnackAPIKey = "xxxx"

$.ajax({url: 'https://api.knackhq.com/v1/objects/object_1/records', type: "GET",
headers: {"X-Knack-Application-Id": KnackAppID, "X-Knack-REST-API-Key":KnackAPIKey},
success: function(data) { //alert('Records Retrieved!' + data.total_records);

for (var i = 0; i < data.total_records; i++) {//alert(data.records[i].field_1);
var cust_conn = [data.records[i].id]
var newdata = {
field_99: i + 1, //Customer Group Number
field_104: cust_conn, //Customer Name
field_102: data.records[i].field_25_raw, //License Number
field_97: record.field_97, //Customer Group Name
field_101: record.field_101_raw[0].id, //Segmentation
field_109: data.records[i].field_103_raw, //Customer segta ID
field_110: data.records[i].field_4_raw, //Specialties
field_111: data.records[i].field_24_raw, //Territories
field_112: data.records[i].field_27_raw, //Organisations
field_113: data.records[i].field_28_raw //Products

}

$.ajax({
url: "https://api.knackhq.com/v1/objects/object_15/records/",
type: "POST",
headers: {'X-Knack-Application-Id': 'xxx', 'X-Knack-REST-API-Key':'xxx'},
data: newdata,
//success: function(response) {alert('Records Added!');}
});
}
Knack.hideSpinner();
}
});
});

id like an answer too