Forum Discussion
Can you post your current code and the error you are receiving? Also, Mark taught me most of what I know, so he'll likely be able to sort this out if I swing and miss!
------------------------------
Mike Tamoush
------------------------------
My current code is
var text URL = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "_fid_20=" & URLEncode("success") & "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]);
and the error I get is
------------------------------
Nolan Pilozo
------------------------------
- MarkShnier__You10 months agoQrew Legend
The issue is that you want a button which will work in both ADD Mode and EDIT mode. But in ADD mode, the Record ID# does not yet exists. So you need to use a field type of Formula Rich Text (not formula URL) and have the button first save the record and then edit it.
var text RID = If([Record ID#]>0, ToText([Record ID#]), "%%rid%%");
var text URL = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & $RID
& "_fid_20=" & URLEncode("success")
& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=") & $RID;
"<a class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration:none; background: #117a39; border-radius: 5px; color: #FFFFFF; display: inline-block; padding: 4px 4px 4px 4px; width:140px; text-align: center; text-shadow: none; border: 2px solid #0863f5; font-size: 12px \"href='"
& $URL
& "'>Set as Success</a>"
------------------------------
Mark Shnier (Your Quickbase Coach)
mark.shnier@gmail.com
------------------------------- NolanPilozo10 months agoQrew Member
I actually don't care about add mode as this will only be done on existing records, so I'm only doing it off of the edit form OR have it as a field in a report and you can just click it to have it go through. I have also tried the "%%rid%%" solution, and copy and pasted this code as well, but still keep coming up with the same error
------------------------------
Nolan Pilozo
------------------------------- MarkShnier__You10 months agoQrew Legend
I just noticed there is an error in this line. Make this correction.
& "&_fid_20=" & URLEncode("success")
------------------------------
Mark Shnier (Your Quickbase Coach)
mark.shnier@gmail.com
------------------------------
- Hongkunliang9 months agoQrew Cadet
Hi Mike,
Thanks for sharing the code. It's very useful.
Any suggestion to add a "delay" before refreshing? When adding this new record, my pipeline also creates some child records. In order to show the newly created child records in the form and avoid refreshing the form again, is it possible to add "delay or wait" between the saving and loading the current record? Thanks in advance!
------------------------------
Hongkun liang
------------------------------- MikeTamoush9 months agoQrew Commander
https://resources.quickbase.com/db/bq8kmgrcq
That is a link to some example code pages someone has made. Look at the example for RunPauseRefresh. I have implememnted that with success. You would run your api call then your redirect would be to that code page, where you can set how many seconds it pauses.
------------------------------
Mike Tamoush
------------------------------