Has anyone had success using a View-based POST? (with ajax is even better) Or is there another way?
I need to enter a new connected record but I am running the api from the child table. (I am basically taking an existing child and splitting it into two records. Each child represents a payment.)
However, the connection to the child is still missing.
The instructions say that the connection is made manually by using field_1 but I cannot get that to work.
(cURL)
–data-raw ‘{
“field_1”: “5d65bad5614e4d001047b585”
}’
So I am sending field_1 with my parent id, but it does not enter the connection.
I have also tried field_1_raw and neither works.
var ParentURL = "https://api.knackhq.com/v1/pages/scene_xxx/views/view_238/records";
var MyDataObject = {
//"field_1": MyParentID, // does not work
"field_1_raw": MyParentID, // does not work
"field_105": SampleVariable,
...
"field_103": 'Approved'
};
DoSomeAjax(ParentURL, 'POST', MyDataObject, function(NewPaymentData) {
console.log(NewPaymentData); // dumps new record, looks good but no connection to parent
var NewPaymentID = NewPaymentData.id;
console.log("Payment " + NewPaymentID + " created.");
});
Hmm, I understand at least what that is trying to do, but it still does not create the connection to the record.
I have tried multiple iterations, with field_1, with field_1_raw, without field_1 at all, with double and single quotes around edit-parent_id
When I type .crumbtrail into my JS code window, it puts … underneath it, does that mean something? It does recognize it as valid for an object because it appears in the data list.
It does add the record, just does not connect it.
MyActivityID = "623c602239e4c8001fcd250a"
var ActivityPaymentURL = "https://api.knackhq.com/v1/pages/scene_xxx/views/view_238/records";
var ActivityPaymentObject = {
"field_1": MyActivityID, // I have tried this
//"field_1_raw": MyActivityID, // and this
...
"field_103": 'Approved'
};
ActivityPaymentObject.crumbtrail={};
ActivityPaymentObject.crumbtrail["edit-parent_id"]=MyActivityID;
Remove
“field_1”: MyActivityID, // I have tried this
//“field_1_raw”: MyActivityID,
if then still not work you can reach out for this on email we can check on your app.
Apparently I could not make that connection that way BECAUSE I had made my connection from the parent table instead of from the child.
I deleted the connection, reconnected from the child table, redid all my forms and views and functions which used the connection (that was fun) and then just posted to the child object in the first place. Sigh. But it WORKS now.