Trouble with URL button to copy a record with custom GUID (key) field
Hi,
I'm trying to create a button that will allow users to copy a record but I'm using my own key field so I need to increment that automatically in the process.
Context: We have an online form for employees to created 'SDO Requests'. These get transferred from the resulting spreadsheet to a Quickbase 'helper' table where some transformations happen and a new GUID is assigned before a pipeline sends them to the master table. The custom GUID is necessary to weed out duplicate entries on import and transfer.
Since these requests involve dates and time periods they sometimes span two pay periods. I'm trying to provide the people that approve and audit the requests an easy way to 'split' a request by making a copy of the original so that they can just edit the end date of the original and start date of the copy (one day I'll dig into how to automate that as well since I have a table of pay periods to reference but I digress).
I have no idea if I'm even on the right path here but my thought was to pass the original GUID (e.g. key) field to the new record and just add the Quickbase generated Record ID# to the end of it to ensure a new unique value. I've tried variations of this:
URLRoot() & "db/" & Dbid() & "?a=GenCopyRecord&rid=" & [Record ID#]
& "&_fid_6=" & URLEncode([SDO Request GUID]&"-"&ToText([Record ID#]))
And so far I either get the same GUID as the original record or it momentarily populates the original GUID but goes blank (I suspect this is a result of me trying to add a concatenated value to the field. Fid_6 is the id of my GUID field.
URL coding is certainly not my strong suit in Quickbase to date so any help would be greatly appreciated. I'm not married to this idea either, I just need to be able to allow users to copy a record and generate any kind of new unique value for fid_6.
Unfortunately, the a=GenCopyRecord function does not allow you to specify values for any fields. It simply puts you into the Add record mode with fields copying forward where the field is flagged to copy forward on the field properties settings.
But instead, you could use this syntax
URLRoot() & "db/" & dbid() & "?act=API_GenAddRecordForm"
& "&_fid_6=" & URLEncode([SDO Request GUID]&"-"&ToText([Record ID#]))
& "&_fid_7=" & URLEncode([my field in field 7])
& "&_fid_8=" & URLEncode([my field in field 8])
& "&_fid_9=" & URLEncode([my field in field 9])
.. So this is pretty easy to do except that you do have to specify every single field to be copied forward.