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!