EarlAdkins
5 years agoQrew Member
Best practice - Updating Record ID after a record save
I'm looking for the best practice to retrieve the Record ID in JavaScript, after having created a new record
in a table.
For convenience I have posted the specific code snipplet below:
/** Debug purposes **/
dump(parms);
if (parms.partner_rid) {
/**
* save QuickBase data for this file upload
*/
$.ajax({
url: "/apps/insurance_uploads/code/upload_insurance_data.php",
type: "post",
data: parms,
dataType: "json",
success: function (row_id) {
if (row_id == "NULL" || row_id == "")
{
/**
* upload was unsuccessful
*/
fn_remove_uploaded_file(files[0]['url']);
$("#modal-upload-failed").modal({
closeClass: 'icon-remove'
});
fn_add_gritter('Unable to complete upload.', 'Your upload was unsuccessful. Please review your actions (did you remember to select an "upload type"?) and try again or call <b>248.688.0024</b> and press "2" for assistance.', 'fa-bomb', 'faa-pulse animated', true);
}
else
{
/**
* upload successful
*/
fn_add_gritter('Confirmation (Row ID): ' + row_id, parms.file_name + ' has been successfully uploaded.<br/>(' + parms.doc_name + ').<br/><br/>Mouse over this alert and click x to close it.', 'fa-bell', 'faa-wrench', true);
/** 10/04/20 - Earl - Added coding to create the companion Document Upload record **/
$.ajax({
url: "/apps/insurance_uploads/code/update_documentupload_data.php",
type: "post",
data: parms,
dataType: "json",
success: function (row_id)
{
fn_add_gritter('Confirmation (Row ID): ' + row_id, parms.file_name + ' had a companion Document Upload record successfully created.<br/><br/>Mouse over this alert and click x to close it.', 'fa-bell', 'faa-wrench', true);
}
});
}
},
failure: function () {
/**
* unsuccessful doc info upload! remove uploaded file
*/
fn_remove_uploaded_file(files[0]['url']);
$("#modal-upload-failed").modal({
closeClass: 'icon-remove'
});
fn_add_gritter(
'Unable to complete upload.',
'Your upload was unsuccessful. Please review your actions and try again or call <b>248.688.0024</b> and press "2" for assistance.',
'fa-animated',
'faa-ring',
true);
}
//async: false
});
} else {
//alert("first pass");
}
} else {
/**
* this path is taken on initial load,
* so no action since file[0] is empty
*/
}
Any assistance would be greatly appreciated.
Thanks,
Earl
------------------------------
Earl Adkins
------------------------------