How do I create a field to show who (a registered user) changed the status of a checkbox or multiple choice text field?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

Here's the scenario: a registered user will be processing invoices for payment.  This person will either click a checkbox called "Ok to Pay" or choose Yes from a multiple choice text field.  Either of these approaches is fine with me, whichever is easier.  Upon either clicking the check box or selecting yes, I'd like to automatically populate a field with the users name who clicks the box or selects yes, thus approving the invoice for payment.

Sorry to be so long-winded, just want to be as clear as possible with my question.  Thanks in advance!

Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
I suggest taking away the manual multiple choice field and instead forcing all users (except perhaps the Admin) to use a button to Approve.

i know that this will look scary, but its the easiest way to make a button which will work for both using the button on reports and records. It does the edit and refreshes the page you are on.

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


& "&apptoken=" & "XXXX"


& "&_fid_100=" & URLEncode (User())

& "&_fid_101=" & "Yes";



"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"




In this example above, I actually suggest turning off the need to use Application Tokens and dropping that line which provides the app token.

I am assuming that you want to populate field ID 100 with the userid of the current user who clicked the button, so that needs to be a field of Type userid, and then I am populating the field ID 101 with the value "Yes".  You will need to adjust those to your actual field ID numbers which can be shown on a field list or the Usage tab for Field Properties.
Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb
I think I can make this happen no problem.  My question next is, and excuse me for being a little slow on this, do I put both formulas in the same box in the formula URL field?
no problem - I knew it would look scary to you, first time.  yes it all goes in one formula box.
Note that you will need to give the URL formula field a link name of that ugly formula will be exposed to the user as the Link text.
Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb
I did right (I think) and got this syntax error:  Formula syntax error:

A variable declaration must end with a semi-colon.


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

& "&apptoken=" & "XXXX"

& "&_fid_45=" & URLEncode (User())

& "&_fid_24=" & "Approved Queue"  )



"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"

Also, I kept the App Tokens on because I'm using them elsewhere.  I'm masking it here.
sorry, I fixed my post above.

this line was corrected to

& "&_fid_101=" & "Yes";
Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb
Suppose I wanted to add a line of code to add the date the button is pushed.  Would the code look something like this

& "&_fid_34=" & URLEncode (Today);

?
& "&_fid_34=" & URLEncode (Today());

The function for today is Today()
Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb
Is there also a way to make this action trigger a notification email?
Sure. Just set up a Notification to trigger when the [OK to Pay] field changes and after the record is saved it has the value Yes.
Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb
So, I'd have to do that by editing the record manually, as opposed to pressing the button in the table view, correct?  Is there a way to do it without having to manually edit the record?
The notification will fire ire the same regardless of whether the button is pushed or the record is edited manually. Notifications have nothing to do with form rules, they simply operate as to if the field got changed somehow and the record was saved. Saving a record includes editing a record by the use of an API.
Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb
Once a button is pressed, I'd like for it to redirect to another page.  This other page will be a form on my site.  Would I modify this code to redirect to that form?  


"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"

If so, what does that code look like?
Can you post your full current formula?  It will need to be changed and will not be using that javascript.  Can you also post the URL that you want to land the user on?  Is it a record or a report or a Dashboard Page.
Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb
Sure!  Here's the formula:

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

& "&_fid_26=" & "No";



"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"

Here's the address of the page I want to redirect to -  https://octo.quickbase.com/db/bkfy5vusa?a=nwr
Try this then.

var text URLONE= URLRoot() & "db/" & Dbid() & "?act=API_EditRecord"
& "&rid=" & URLEncode ([Record ID#])
& "&_fid_26=" & "No";

var text URLTWO = urlroot() & "db/" & [_DBID_ and insert the rest of the table name here] & "?a=nwr";

 $URLONE
& "&rdr=" & URLEncode($URLTWO)

The advanced properties tab of the table shows its _DBID_ name
Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb
I think I forgot to say something.  When it redirects to that website, I'd like for it to redirect to the that website for that specific record.  As written right now, it marks 26 with a no and then opens the form to create a new record, instead of editing the existing record that we're marking as No.
OK, well, yes, that is different.
try this then.

var text URLONE= URLRoot() & "db/" & Dbid() & "?act=API_EditRecord"
& "&rid=" & URLEncode ([Record ID#])
& "&_fid_26=" & "No";

var text URLTWO = urlroot() & "db/" & dbid() & "?a=er&rid=" & ToText(Record ID#]);

 $URLONE
& "&rdr=" & URLEncode($URLTWO)

By the way, I had posted a demo app in the Exchange called URL formula buttons for Dummies.  I suggest that you down load that and get the basics of building buttons which string successive actions together.  Just go to create new app, and then it will offer the Exchange and search on Dummies.
Photo of Jay (DDS)

Jay (DDS)

  • 430 Points 250 badge 2x thumb
Will do!  BTW, cut and pasted the above in and got this error:  

The argument list of the function Record must begin with a left parenthesis.


var text URLONE= URLRoot() & "db/" & Dbid() & "?act=API_EditRecord"
& "&rid=" & URLEncode ([Record ID#])
& "&_fid_26=" & "No";

var text URLTWO = urlroot() & "db/" & dbid() & "?a=er&rid=" & ToText(Record   ID#]);

 $URLONE
& "&rdr=" & URLEncode($URLTWO)
change that to
var text URLTWO = urlroot() & "db/" & dbid() & "?a=er&rid=" & ToText([Record ID#]);