Forum Discussion
------------------------------
Harrison Hersch
------------------------------
- EarlAdkins5 years agoQrew Member
Hi Harrison,
The business case is this:
Currently our Deployment Partners are required to provide Insurance Certificates. This is currently being provide to us via email.
In the faith of automating more processes we are moving to allow the Deployment Partners to upload their Insurance Certificates
along with the respective information related to them.
The code resides in a jquery.fileupload-ui.js page which is accessed via an ajax POST to the specific php pages.
Currently after the form is filled out by the Deployment Partner they are allowed to select a file (Insurance Certificate) for upload and prompted to choose the Upload type (Insurance Coverage Type).
Once the upload button is pressed a QB record is added to an Insurance table with the form data they provided. If successful the next process executes uploading the file (Insurance Certificate), a record 'add' to the Document Uploads table returning the Row-ID.
There is a text field in the Document Uploads table called 'QuickBase RID'. This is slightly misleading as it is a reference field that is text.
The problem is I am having difficulty getting the 'QuickBase RID' field to update with the returned Row-ID from the Document Upload.
I have included the QB add and update code below:<?php set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"]); require_once "common/QuickBase/classes/QuickBaseUpdate.class.php"; foreach ($_REQUEST as $k => $v) { $_REQUEST[$k] = urldecode($v); } $TRUE_VALS = array("yes", "Yes", "true", "True", "On", "on", 1, "1", True); /** * params come from function "_renderDownload" in file "jquery.fileupload-ui.js" */ $qb_table = isset($_REQUEST["qb_table"]) && $_REQUEST["qb_table"] > "" ? $_REQUEST["qb_table"] : "bmtpe4qh3"; // QuickBase Table name $qb_rid = isset($_REQUEST["qb_rid"]) && $_REQUEST["qb_rid"] > "" ? $_REQUEST["qb_rid"] : "unknown"; // QuickBase Record ID $partner_rid = isset($_REQUEST["partner_rid"]) && $_REQUEST["partner_rid"] > "" ? $_REQUEST["partner_rid"] : 0; // partner RID $coverage = isset($_REQUEST["coverage"]) && $_REQUEST["coverage"] > "" ? $_REQUEST["coverage"] : "Automobile"; // coverage $doc_type = $coverage; // doc_type $doc_name = isset($_REQUEST["doc_name"]) && $_REQUEST["doc_name"] > "" ? $_REQUEST["doc_name"] : "unknown"; // document (original) name $file_name = isset($_REQUEST["file_name"]) && $_REQUEST["file_name"] > "" ? $_REQUEST["file_name"] : "unknown"; // file name $file_link = isset($_REQUEST["file_link"]) && $_REQUEST["file_link"] > "" ? $_REQUEST["file_link"] : "unknown"; // path to file $uploaded_by = isset($_REQUEST["uploaded_by"]) && $_REQUEST["uploaded_by"] > "" ? $_REQUEST["uploaded_by"] : "Earl Adkins"; $uploader_email = isset($_REQUEST["uploader_email"]) && $_REQUEST["uploader_email"] > "" ? $_REQUEST["uploader_email"] : "eadkins@fedcap.com"; $partner_name = isset($_REQUEST["partner_name"]) && $_REQUEST["partner_name"] > "" ? $_REQUEST["partner_name"] : 0; // partner name /** now update the Documents Uploads info * * Update: 10/06/20 - Earl - Added to create a 'Documents Upload' record for the file */ $table_id = "bmtpe4qh3"; $rec = '[{' . '"Related Deployment Company":"' . trim($partner_rid) . '","Document Type":"' . trim('Insurance - ' . $coverage) . '","Document Name":"' . trim($doc_name) . '","File Name":"' . trim($file_name) . '","File Link":"' . trim($file_link) . '","Uploaded By":"' . trim($uploaded_by) . '","Uploaded On":"' . date("Y-m-d H:i:s") . '","Upload ":"' . trim($uploaded_by) . '","Related":"' . trim($partner_rid) . '","QuickBase Table":"' . $qb_table . '","Other Party":"' . 'n/a' . '","Contact Type":"' . 'n/a' . '","Assignee":"' . 'n/a' . '","Assignment Type":"' . 'n/a' . '"}]'; $qbo = new QuickBaseUpdate($table_id, "add", $rec); $rst = json_decode($qbo->json); $qb_rid = json_encode($rst[0]->{"rid"}); // return update_id or rid /** * $this->result = json_decode('{"action":"API_AddRecord","errcode":"0","errtext":"No error","rid":"97","update_id":"1368712078584"}'); */ /** unset($qbo); // try this to see if we need to clean up old objects -- may need to leave out iot access qb_rid later **/ echo $qb_rid; $QB_rid = $qb_rid; echo $QB_rid; /** 10/09/20 - Earl - Update the Document Upload record using the 'row_id' generated from the File Upload **/ $rec = '[{' . '"QuickBase RID":"' . $QB_rid . '"}]'; $qbu = new QuickBaseUpdate('bmtpe4qh3', 'upd', $rec); $rst = json_decode($qbu->json); $upd = json_encode($rst); unset($qbu); echo($upd->json);
------------------------------
Earl Adkins
------------------------------