Javascript Prompt + Edit record for Decline button

  • 0
  • 1
  • Question
  • Updated 12 months ago
  • Answered

I am trying to figure out , a way to combine the url formula button in quickbase with a Javascript Prompt and the data entered to be automatically be entered into the text field using api-edit record function.

Combining API-Edit record with Javascript with Url button.

I have created the code separately, but I cant combine them into the button.


Code for edit:

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

& "&_fid_13=has denied this request." - to be replaced with JavaScript input variable

& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?act=dr&rid=" & [Record ID#])

Code for JavaScript Prompt

"javascript:var a = prompt('Enter your reason: ', '')"

Thank you
Photo of Arun

Arun

  • 20 Points

Posted 5 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,074 Points 20k badge 2x thumb
If you have an rdr parameter in your formula you are doing it wrong. Using an rdr parameter is an outdated mechanism to string together two GET requests in sequence and it has considerable shortcomings. Always use script.

The following record has a formula definition that will cause a user defined page of JavaScript to be loaded and executed. Put all of your logic and AJAX calls in the script.

Pastie Database

https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=241


Pass as few variables as possible (eg QBU_rid) to the script using the formula language. You are better off recalculating or making an AJAX request to get the inputs your script needs to complete that required action rather than make your formulas more unreadable by passing variables (such as QBU_rid). I tested this script and it does exactly what you request.
Photo of Carlos

Carlos

  • 796 Points 500 badge 2x thumb
Dan, does this require IOL? I can't seem to get the button (in a formula Text or Formula URL Field) or the API to work
Photo of Carlos

Carlos

  • 796 Points 500 badge 2x thumb
Nevermind. Got it to work!
Photo of Micro Dev

Micro Dev

  • 1,454 Points 1k badge 2x thumb
How can I implement this to edit a record id of a different table in my app?

Thanks
Photo of Micro Dev

Micro Dev

  • 1,454 Points 1k badge 2x thumb
I mean a record of a different table in my app? (the record id will be [maximum record id#])

Thanks
Photo of Arun

Arun

  • 20 Points
Thank you Dan,

Going forward i will put the logic into Javascript and use AJAX calls in the script.
Photo of Akmal

Akmal

  • 0 Points
I have the same situation, would either of you help me out please?
Photo of Arun

Arun

  • 20 Points
Hey Akmal,

What are you stuck on?
Photo of Akmal

Akmal

  • 0 Points
If([On-Hold]<>true,URLRoot()&"db/"&Dbid()&"?a=API_EditRecord&rid="&[Task ID]&"&apptoken=be4************zk5nh"&"&_fid_179="&URLEncode(true)& "&rdr="&URLEncode("https://milehighgraphics.quickbase.com/db/bji*****3"),"javascript:alert('THIS TASK HAS ALREADY BEEN STARTED')")

//This is my url code to edit record but I need to include the prompt//

Thank you for taking the time to help me.
Photo of Jonathan Roberts

Jonathan Roberts

  • 338 Points 250 badge 2x thumb
I know this is old but, is it possible to have it return to where ever it was press and not on the changed record?