How do I edit and save a record with a url button on the report?

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

I have a [due date] field that autofills based on dynamic form rules when a [paid] box is checked. 

I have a [url] button on my report that changes the [paid] box to TRUE when pressed. I would then like the [due date] field to change based on the dynamic form rule. In order to do so, I want my [url] button to also open the edit form of the record, and then save it, just so the dynamic form rules come into play. 

What would I have to include in the [url] button to get it to trigger the dynamic form rules?

Photo of Matthew

Matthew

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Well, you cannot trigger dynamic form rules unless you put the form into edit mode.  What value do you want to have in the [Due Date] field.  Why not just have the URL formula update that field too?
Photo of Matthew

Matthew

  • 0 Points
The value in [due date] is pulled in from three other date-formula fields that calculate a new due date after [paid] has been checked. The [due date] is also changed to a text field (via form rules) when another field is changed and when a certain number of payments have been made.

I've tried using the URL formula to update, but I get an error: "incorrect variable type. The type of the variable does not match the return type of the expression."

The [url] button works fine if you take out the lines with //**********
Currently, my [url] button is:

var bool checkedstate = (If([Paid], false, true)) ;
var bool checkedstateTWO = (If([Paid], true, true)) ;
var bool checkedstateTHREE = (If([Paid], true, true)) ;
var date checkdate = (If([Paid 3rd]=true, [due date]=[new due date], [due date]=[due date]));  //*********

URLRoot()

& "db/"

& Dbid()

& "?a=API_EditRecord"

& "&rid="

& [Record ID#]

& "&_fid_54="
& $checkedstate

& "&_fid_53="
& $checkedstateTWO

& "&_fid_43="
& $checkedstateTHREE

& "&_fid_48=" //**********
& $checkdate //**********

& "&rdr="

& URLEncode(URLRoot() & "db/" & Dbid() & "?a=q&qid=" & "12")
try this

var bool checkedstate = If([Paid], false, true) ;
var bool checkedstateTWO = If([Paid], true, true) ;  // this is strange as its always true
var bool checkedstateTHREE = If([Paid], true, true) ;  // this is strange as its always true
var date checkdate = If([Paid 3rd]=true, [new due date], [due date])); 

URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" & "&rid=" & [Record ID#]

& "&_fid_54=" & $checkedstate

& "&_fid_53=" & $checkedstateTWO

& "&_fid_43=" & $checkedstateTHREE

& "&_fid_48=" & totext($checkdate)

& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=q&qid=" & "12")
Photo of Matthew

Matthew

  • 0 Points
Thank you! That works for the most part.

So is there no way to replace [due date] with text?

As a side note, the checkedstateTWO and THREE are always true because this is the formula for just one of my buttons, so other buttons trigger the TWO and THREE fields, and because the current checkedstate is the third in a line of checkboxes, I wanted the current checked state to mark the previous boxes true but not unmark them if the current checkbox was unchecked. Not sure if that makes sense, but the TWO and THREE variables are set up as always true for a reason.
The current formula will ALWAYS change field IDs 53 and 43 to true.  If you want a different behavior, post back and i can help you with that.

I'm not understanding this question: "So is there no way to replace [due date] with text?"

What field ID holds [Due Date]?   But regardless, if you are asking if you can stuff random words into a date field, then answer is no.  It's the same as If you try to manually enter words like "not yet due" into a date field.  QuickBase will not let you save invalid words into a date field, manually entered.  It only accepts dates which it can interpret as a date.
Photo of Matthew

Matthew

  • 0 Points
Yes, I want the current formula to always change field IDs 53 and 43 to true. The current formula is [3], and field IDs 53 and 43 are [2] and [1]. If [3] is checked, I want it to check both [1] and [2]. And if [3] is subsequently unchecked, I want [1] and [2] to stay checked.

Other url formulas dictate when [1] and [2] become unchecked.

[Due date] is field #48 and is a date type.
Your explanation makes sense. The reason I was looking for a way to "open the edit page and click save" within this url formula was because the dynamic form rules I currently have in place allow the [due date] field to hold a text, for example, to say "fully paid," after the final payment checkbox is checked. I guess the dynamic form rules somehow bypass the type of the field somehow.
OK, I learned something when you say that you did manage to stuff words into a date field.  But when you edit the record manually to edit other fields it may not save. its a loophole really that may be closed on your in the future.  

But I would not do it that way.  I would make a new formula text field and if the condition is fully paid, say a checkbox field, then make the words "fully paid" else totext ([due date]).  So it will be a field that looks like a date, but is really just text.

I still don't understand your checkboxes, but I guess you willfnd ot of they are working like you wnat them to work.  when you say "I want [1] and [2] to stay checked", that would mean that you need to be silent on the action for those fields in your formula, so the line in your formula for
& "&_fid_53=" & $checkedstateTWO

& "&_fid_43=" & $checkedstateTHREE

would need to have an IF around them