Is there a way to add a button to a record that will cause a change to be made to the record when clicked?

  • 1
  • 1
  • Question
  • Updated 1 year ago
  • Answered

I was wondering if there was a way to add a button to a record that when clicked would change a field in that record without having to go into edit mode?

For instance, I what to be able to change the status of a record from "On Hand" to "Retired" but just clicking on a button that is available from the report view. The reason this would be helpful is that if I am looking at a list of records that need to be retired, I now I could click grid edit and just change the status dropdown and then fill down, but I am trying to make the process as streamlined and simple for machine operators on the floor to do the updates.

Photo of Chris_MCD

Chris_MCD

  • 0 Points

Posted 5 years ago

  • 1
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
I did a Blog Article which is about to be published and an App in the Exchange called URL formulas for Dummies. it has come examples, and my Blog article.


https://qdfc.quickbase.com/db/main?a=AppDetail&ID=1803&app_name=URL%20Formula%20Buttons%20for%20Dumm...

Post back if you have questions! Or even if you don't, let me know what you think of the article.


Photo of Troy Tyler

Troy Tyler

  • 180 Points 100 badge 2x thumb
This link seems to not be public, or am I missing something? Would love to have the resources!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
Can you go to the Exchange and search on Dummies. The app will come up in a search there.
Photo of Kingsly SD Samuel

Kingsly SD Samuel

  • 776 Points 500 badge 2x thumb
I am not able to access this site with my regular login to QB. Can I be given access to this? Thanks.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
Everyone has access to the Exchange. Go to your My Apps page and then go to Create a new app and there will be a link to The Excgnage there where there are many free apps.
(Edited)
Photo of Chris_MCD

Chris_MCD

  • 0 Points
Ok, so this is pretty awesome! I just applied the 2nd example to what I was going for and it works swimmingly! The one question I do have is that instead of having it show the record after the function is complete, you had mentioned you could have it show a report instead? What part of the URL address for the report is the part I would need to substitute in for the [Record ID#]?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
If you are using a conventrion of URLTWO for what it does next after the edit, then it would just be like
URLRoot() & "db/" & dbid() & "?a=q&qid=xx"

ie in English this says , go to my app and go to the table I am already in (that's the dbid() part) and the Action is to run a Query "a=q"  (QuickBase used to call reports "queries" and the Query ID number id xx  (&qid=xx).  So just run the report that you want to refresh and observe the Query ID number in the URL at the top of the browser.

e.g. URLRoot() & "db/" & dbid() & "?a=q&qid=22"
Photo of Chris_MCD

Chris_MCD

  • 0 Points
oh ok, yup that worked! This is really cool. I still don't have a perfect handle on it but I will continue to study your article. The only downfall for this particular application is that am using a report that utilizes the _ask1_ so a user can bring up several records at once. The issue there however is that if the user the clicks the button on the first one, it then takes them back to report with all the blank entry boxes versus the list of records that was previously pulled. But this in general will definitely come in handy down the road as I develop our system further. Thanks for the help!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
There is an alternative, since you passed URL for Dummies with flying colors and are ready for Advanced URL formulas for Dummies.

Try this one

Do your URLONE formula except if you are just doing one thing, like editing one record, then let's just call it URL as the formula variable.

so you have var text URL = ........:

So it would look like this:

var text URL = URLRoot() & "db/" & "?act=API_EditRecord&_fid_80=1&rid=" & [Record ID#];

"javascript:" &
"$.get('" &
$url &
"',function(){" &
"$.jGrowl('This Item has been put on PO CANCEL snooze', {life: 5000, theme: 'jGrowl-green'});" &
"});" &
"void(0);"

This will put up a fade away pop up and not refresh the report.  The fade will last for 5,000 miliseconds (5 seconds), and the box will have the words in those single quotes
Photo of Chris_MCD

Chris_MCD

  • 0 Points
Man, you are a friggin genius! That did the trick, thanks so much!!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
Adding button to an app can really improve the ease of use for the users for those simple operations like flagging records as completed to updating a field with "Today()"  :)
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
The application below contains one table with fields for [Name], [Phone], [Email] and [RSVP]. If you click the button the [RSVP] will change to NO and the report will reload:

Update Clicked Record From Report
https://haversineconsulting.quickbase.com/db/bjdv4942n?a=q&qid=2

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=347

Note that if the fields you want to change would result in (1) the report displaying stale information, or (2) the record would no longer meet the report criteria you have to reload the page to keep the displayed report consistent with internal state of the table.

The formula for the image onload field [-] has the normal definition and is concatenated with the HTML for the button:

[iol] & "module.js" & [/iol] &
"<a class='Success Vibrant QBU_ChangeRSVP'>" & "Change RSVP" & "</a>"

You don't need to put any onclick handler on the button as you can detect the button was clicked in module.js. The class QBU_ChangeRSVP has no CSS definition associated with it and is only used to easily select the custom buttons that are inserted into the report.
Photo of Chris_MCD

Chris_MCD

  • 0 Points
So I was trying to incorporate this last formula to be used to mark a task as complete. And everything saved correctly for the field but when I click the button, it is not changing the checkbox field to checked. I do get the fade away popup though. Not sure what is wrong with the formula. Here is what I have.

var text URL = URLRoot() & "db/" & "?act=API_EditRecord&_fid_9=1&rid=" & [Record ID#];

"javascript:" &
"$.get('" &
$url &
"',function(){" &
"$.jGrowl('This box has been retired', {life: 5000, theme: 'jGrowl-green'});" &
"});" &
"void(0);"

I know I have the right field ID in there. Am I missing something?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
The fade away poop up will always happen, regardless of if the actually update blows up like a nuclear bomb in the background.  Dan Dielbolt would admonish us that that is a deficiency of this URL for Dummies approach.

You URL is not telling QB which table to update!

var text URL = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&_fid_9=1&rid=" & [Record ID#];
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
You are probably missing the application token. Be that as it may be, the only JavaScript you should put into a QuickBase formula is a $.getScript() call and place all of your functional JavaScript in a user defined page. module.js. You are just asking for trouble writing JavaScript in a formula as there will constantly be character escaping issues Moreover, even if you only want your JavaScript to run on a button click you should use the image onload technique and put an event handler in the user defined page module.js rather than jam a callback or or an inline onload handler in your formula.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
sorry Chris,

just updated my formula above
var text URL = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&_fid_9=1&rid=" & [Record ID#];
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
QBC>Dan Dielbolt would admonish us that that is a deficiency of this URL for Dummies approach.

Read the book:

http://i.imgur.com/NZP7Si2.jpg

https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=294
Photo of Chris_MCD

Chris_MCD

  • 0 Points
I am now getting this error,

Formula syntax error

A variable declaration must end with a semi-colon.



var text URL = URLRoot() & "db/" & dbid()   "?act=API_EditRecord&_fid_9=1&rid=" & [Record ID#];

 "javascript:" &
 "$.get('" &
 $url &
 "',function(){" &
 "$.jGrowl('This Task has been completed', {life: 5000, theme: 'jGrowl-green'});" &
 "});" &
 "void(0);"
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
var text URL = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&_fid_9=1&rid=" & [Record ID#];
Photo of Chris_MCD

Chris_MCD

  • 0 Points
Ok, I think I got it now. But let me ask you this... in testing this out, I have clicked the button, and then went into the record to make sure it worked, and the first time it did. But then once I have changed it back and then tried it again, it no longer worked. Why is that? I still worked on a different record when I tried it on that one.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
It should work consistently every time.  No way it would not work for a simply update like that.  Please test again.
Photo of Chris_MCD

Chris_MCD

  • 0 Points
I have actually tried it 3 times now, twice with my companies system an another with the other company I work with. It seems as though once you change a record using the button, then update that record back to its original state, when you go through the process again, the button no longer works on that record. Something must change about it. I don't see this really being an issue as once the button is used on a record, there really is no reason to change it back in most cases. I was just simply testing it out.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,168 Points 50k badge 2x thumb
maybe make this minor chnage
var text URL = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&_fid_9=1&rid=" & totext([Record ID#]);
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
Try Plan B: script using the image onload technique. It always works the first time!