Forum Discussion
DawnQuitschau
4 years agoQrew Member
Sharon, thanks for the quick response. The code you provided is what I started with when I created my custom button, however, it still doesn't return the updated Asset ID. (It appears to perform the same functionality as the native Quickbase "Save and Keep Working" button.) I can see the record was saved and it does return the Record ID# and temp id, but the Asset ID is still set to 1. If I click on the browser refresh button to manually refresh the browser window, the updated Asset ID appears. So somehow, I need to mimick that functionality. Or provide a delay between the save and re-display to allow the pipeline to run following the save.
------------------------------
Dawn Quitschau
------------------------------
------------------------------
Dawn Quitschau
------------------------------
QuickBaseJunkie
Qrew Legend
4 years agoAh, okay.
Using a Pipeline in this scenario to update the key will be slow, so I wouldn't take that route for the first part (updating the key).
I have 2 suggestions:
-Sharon
------------------------------
Sharon Faust (QuickBaseJunkie.com)
Founder, Quick Base Junkie
https://quickbasejunkie.com
------------------------------
Using a Pipeline in this scenario to update the key will be slow, so I wouldn't take that route for the first part (updating the key).
I have 2 suggestions:
- Use a form rule to copy the temp id to the Asset ID on save. Below is an image of an example that I have working in an app where the "Rate ID (Rate Type)" is the key field. I like this option because you can use the native save buttons.
- Use an API action button to copy the value from the temp id to the Asset ID. This would be the approach you originally started with but with the addition of the API. It would require the user to use this button in order for the key to update. Below is the button I'd create if I were doing this myself. (Note the key field id '7' on line 5 would need to be updated with the id for the Asset ID, the [Temp ID] for your field name, as well as the apptoken on the next line).
var text NEW =
URLRoot() & "db/" & Dbid() &
"?a=API_EditRecord" &
"&rid=%%rid%%" &
"&_fid_7=" & URLEncode([Temp ID]) &
"&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxxxxx" &
"&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=er&rid=") & "%%rid%%";
var text SAVE =
URLRoot() & "db/" & Dbid() &
"?a=er&rid=" & [Record ID#];
var text URL = If(IsNull([Record ID#]),$NEW,$SAVE);
"<a class='btn btn-md btn-success SaveBeforeNavigating' style='color:white; text-decoration:none;' data-replaceRid=true href='" & $URL & "'>Save & Keep Working</a>"
If you want to learn more about action buttons I have a free toolbox called the Action Button Toolbox.
-Sharon
------------------------------
Sharon Faust (QuickBaseJunkie.com)
Founder, Quick Base Junkie
https://quickbasejunkie.com
------------------------------
- DawnQuitschau4 years agoQrew MemberSharon, I tried both of these approaches and I get the same error - when I click on "Save and Keep Working" (native QB button in the first example) I get a pop-up that says "On the tab Asset, the field Asset ID is required." When I click OK, I'm returned to the Assets form, which is showing the Asset ID is blank and temp id is set to 3 question marks (???).
------------------------------
Dawn Quitschau
------------------------------- QuickBaseJunkie4 years ago
Qrew Legend
I'm not sure why you're getting that and I didn't in my tests. Here are some questions to help you troubleshoot.
How is the formula derived? What are the inputs? Do they come from a relationship?
Also, do you still have the default id of "1" entered in the Asset ID field?
------------------------------
Sharon Faust (QuickBaseJunkie.com)
Founder, Quick Base Junkie
https://quickbasejunkie.com
------------------------------