Forum Discussion
- QuickBaseCoachDQrew CaptainAre you trying to make a button to be used in Virw Mode or a checkbox yo be used in Edit Mode?
- JeffMickelsenQrew CadetBoth. Although I did not think in terms of a checkbox. I have written quite a bit of VBA code in Access and was thinking of a simple push button to execute code when depressed
Sorry if the question is dumb, but I am brand new on QuickBase and I am having some issues figuring out stuff like this. - QuickBaseCoachDQrew CaptainHere is some code which will do that. I also have an app in the Exchange called
URL Formuals for Dummies, which helps explain how to write URL formula buttons.
vat text URL = urlroot() & "db/" & dbid() & "?act=API_EditRecord" & rid=" & [Record ID#]
& "&_fid_999=" & URLEncode(Now());
"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
The first line creates a formula variable called URL which does the edit. You will need to set 999 to the field ID which is being set to Now(). Here is some help on formula variables if you have never used them. https://help.quickbase.com/user-assistance/formula_variables.html
The second part is a handy snippet which simply runs the URL and refreshes the page.- QuickBaseCoachDQrew CaptainCorrect vat to var.
- JeffMickelsenQrew CadetThanks for the quick reply. I will definitely download your URL app from the Exchange..
- ROBERTSACHSQrew CadetI have a similar issue: I have a text field "Events" which I use to log events. Each event is just a text string:
DD/MM/YY text.
The events are listed LIFO (most recent first).
I would like to button to insert (append) the current date into the field. From there I'll type the text.
I tried the above (correct vat to var) and nothing happens. Here is what I have
var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord" & "rid=" & [RecordID#] & "&_fid_44=" & URLEncode(Now());
"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
where 44 is the field ID of the Events field.
Please advise. - QuickBaseCoachDQrew CaptainWhen using this syntax, any error message are hidden.
To debug, you would comment out or remove the JavaScript refresh stuff and replace it with $URL
That will run the URL and expose any error messages.
But I will bet that your app has the need for Application Tokens enables.
So either go to sett8ngs for the app and app properties and uncheck app tokens or else create an app token and add that into the URL formula
& "&apptoken=chfhfghcggdstyujb"
To comment out a part of a formula put // at the beginning if the line. - ROBERTSACHSQrew CadetThanks. The app tokens are already enabled (app token unchecked).
I understand how to comment out, but I don't understand what you mean by doing AND replacing it with $URL? - QuickBaseCoachDQrew CaptainOne way to debug us to make a new field with just the code to do the edit and see if it works
URLRoot() & "db/" & Dbid() & "?act=API_EditRecord" & "rid=" & [RecordID#] & "&_fid_44=" & URLEncode(Now())
That will return a message to the screen as to if the edit was successful or not. - ROBERTSACHSQrew CadetNope. From inside the record, it returned me to the home page, without creating any entry in the field.
I should have realized this before: I have an existing button that I use to generate an email. (You help on that one; thanks). After I send the email, I have been manually logging the event in the events field, as I said.
So really, what should happen is this: once I click the button to generate the email, it should do that, and then append the text to the events field. Here is the current button
"mailto:xxxx@yyyyy.com" &
"?subject="&[Email.SubjectLine: blahblah]&
""&"&body="&[Email.Body-blahblah]&""
I can't add the formula above, I get a compile error.
The text to appended to the top would be:
(Now()) & "text - ROBERTSACHSQrew CadetI created a test field (fid=155) and tried this:
var text URLONE = URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&_rid=" & [RecordID#]
& "&_fid_155=" & URLEncode("Hello");
var text URLTWO = URLRoot() & "db/" & Dbid()
& "?a=dr&rid=" & ToText([RecordID#]);
$URLONE
& "&rdr=" & URLEncode($URLTWO)
that did not work. No update to the field.
I also commented out the URLTWO etc. and used the javascript
"javascript:" &
"$.get('" &
$URLONE &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
That did not work either.
What am I doing wrong?