Forum Discussion

ArunPrasanth's avatar
ArunPrasanth
Qrew Trainee
11 years ago

Javascript Prompt + Edit record for Decline button

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

10 Replies

  • 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.
    • CarlosCarlos's avatar
      CarlosCarlos
      Qrew Assistant Captain
      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
    • EOMDevelepors's avatar
      EOMDevelepors
      Qrew Captain
      How can I implement this to edit a record id of a different table in my app?

      Thanks
  • Thank you Dan,

    Going forward i will put the logic into Javascript and use AJAX calls in the script.
  • 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?