How do I change a dropdown field when I formula URL button is clicked?

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

There is a formula URL button to "Approve" Purchase Orders. There is a Status dropdown. The status should change to "Approved" when the button is clicked, but does not.

I can't figure out any form rules or conditions to make it work. Here is the formula:


If([PO Status Log]<>"Approved",

"<a style='font-weight:bold' class='Vibrant Primary' href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] &

 "&apptoken=dwnt9wipc3cvfcg6nvd3ba97ps4&_fid_54=Approved&_fid_37=" & UserToEmail(User()) & "&_fid_39=" & Now() &  "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]) & "'>Approve PO</a>",

 "<a style='font-weight:bold' class='Vibrant Snowy' href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] &

 "&apptoken=dwnt9wipc3cvfcg6nvd3ba97ps4&_fid_54=Waiting for Approval&_fid_37=" & null& "&_fid_39=" &null &  "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]) & "'>Remove Approval</a>"

)


Thank you

Photo of Ian

Ian

  • 0 Points

Posted 3 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 65,542 Points 50k badge 2x thumb
In my experience, I have never been able to get a redirect to work in conjunction with an href format.  I suggest that you get this working first with a regular URL formula field.  Have you tried that?
Photo of Ian

Ian

  • 0 Points
As in, not a button?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,542 Points 50k badge 2x thumb
The field type should be formula URL.  It will still look like a button, just a boring grey color.

If([PO Status Log]<>"Approved",

urlroot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
&  "&apptoken=dwnt9wipc3cvfcg6nvd3ba97ps4"
& "&_fid_54=Approved"
& "&_fid_37=" & UserToEmail(User())
& "&_fid_39=" & totext(Now())
&  "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]),

 urlroot()  & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
&  "&apptoken=dwnt9wipc3cvfcg6nvd3ba97ps4"
& "&_fid_54=urlencode("Waiting for Approval")
& "&_fid_37="
& "&_fid_39="  
&  "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#])
)
Photo of Ian

Ian

  • 0 Points
I'm getting a syntax error. Also, in your formula, what should the field be named? I'm trying to use "Approve". Thanks
Photo of Gaurav Sharma

Gaurav Sharma

  • 5,884 Points 5k badge 2x thumb
Actually Lan, if you want to change in dropdown field then, you should use as same option that is in dropdown link in your formula, we can't push Approve because there is no option in dropdown like this.
Photo of Gaurav Sharma

Gaurav Sharma

  • 5,884 Points 5k badge 2x thumb
Hi Lan,

Can you try this.

If([PO Status Log]<>"Approved",

URLRoot() & "db/" & Dbid()
& "?a=API_EditRecord&rid=" & [Record ID#]
&"&_fid_54="&URLEncode("Approved")
&"&_fid_37="&UserToEmail(User())
&"&_fid_39="&ToText(Now())
& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]),

URLRoot() & "db/" & Dbid()
& "?a=API_EditRecord&rid=" & [Record ID#]
&"&_fid_54="&URLEncode("Wating for Approval")
&"&_fid_37="&""
&"&_fid_39="&""
& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]))


Thanks,
Gaurav Sharma
Photo of Ian

Ian

  • 0 Points
Gaurav, your formula was accepted, but when trying to use the field to change the approval status, I got an XML error:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<qdbapi>
<action>API_EditRecord</action>
<errcode>24</errcode>
<errtext>Invalid Application Token</errtext>
<errdetail>An Application Token must be supplied.</errdetail>
</qdbapi>
Photo of Gaurav Sharma

Gaurav Sharma

  • 5,884 Points 5k badge 2x thumb
Hi Lan,

This is because i have not used application token.

Use this

If([PO Status Log]<>"Approved",

URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&apptoken=dwnt9wipc3cvfcg6nvd3ba97ps4&rid=" & [Record ID#]
&"&_fid_54="&URLEncode("Approved")
&"&_fid_37="&UserToEmail(User())
&"&_fid_39="&ToText(Now())
& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]),

URLRoot() & "db/" & Dbid()
& "?act=API_EditRecord&apptoken=dwnt9wipc3cvfcg6nvd3ba97ps4&rid=" & [Record ID#]
&"&_fid_54="&URLEncode("Wating for Approval")
&"&_fid_37="&""
&"&_fid_39="&""
& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]))

Thanks,
Gaurav Sharma
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,542 Points 50k badge 2x thumb
I suggest that you go into settings, then app properties and turn off the need for application tokens.
Photo of Gaurav Sharma

Gaurav Sharma

  • 5,884 Points 5k badge 2x thumb
Hi Mark,

I am also not like to use application tokes.