Forum Discussion

AndrewFry's avatar
AndrewFry
Qrew Assistant Captain
6 years ago

Embedded button: URL Syntax

I think my syntax is wrong, but I am unsure as to where exactly.

I have a URL button in a child table that edits a few fields.
I have that button in an embedded report in the parent form.
My goal is to be able to click that button from within the parent form, have the edits made to the child record, and then return back to the parent form.

Here is my simple code:

URLRoot() & "db/" & Dbid()
& "?act=API_EDITRecord&rid=" & [Job ID#]
& "&_fid_177=" & Now()
& "&_fid_178=" & UserToName(User(), "FF")
& "&z=" & Rurl()

The changes are made but it doesn't return back to the parent record form. It gives me a XML error message.

My thought is that although I am clicking the button from within the parent record form, I am not passing down the Parent Record ID# so that the button can return to the correct Parent record form. Am I close???

------------------------------
Andrew
andrew.fry25@gmail.com
------------------------------
  • Hi Andrew, 

    What is the error message that you are getting?  The RUrl will not work in this instance.  You are using the EditRecord API, which will edit the record without any user interaction beyond pressing the button.  This means that you would need to use "&rdr=" & URLEncode(URLRoot() & "db/" & DBID() & "?a=dr&rid=" & Primary Key Field) or you would need to use "key " instead of rid if you are using a primary key other than the default record id.  This should get you back to the parent record.

    ------------------------------
    Brandon Drake
    JHI Group
    Monroeville OH
    ------------------------------
    • MarkShnier__You's avatar
      MarkShnier__You
      Icon for Qrew Legend rankQrew Legend
      .. or here is alternate syntax

      var text URL = 
      URLRoot() & "db/" & Dbid()
      & "?act=API_EDITRecord&rid=" & [Job ID#]
      & "&_fid_177=" & Now()
      & "&_fid_178=" & UserToName(User(), "FF");

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



      ------------------------------
      Mark Shnier (YQC)
      Quick Base Solution Provider
      Your Quick Base Coach
      http://QuickBaseCoach.com
      mark.shnier@gmail.com
      ------------------------------
      • AndrewFry's avatar
        AndrewFry
        Qrew Assistant Captain
        Thanks Mark!

        I will give this a try.

        I keep reading over and over in different places that JS is currently unofficially supported by QB And that QB could remove any use of JS from QB at any time.

        How "safe" is it to use JS code when it could be dropped at any time from QB?

        ------------------------------
        Andrew
        andrew.fry25@gmail.com
        ------------------------------
    • AndrewFry's avatar
      AndrewFry
      Qrew Assistant Captain
      Brandon,

      Thanks for the response. I am still trying to learn the ins and outs of all this. Trial by fire I guess!!

      After you mentioned the redirect line, I realized that I had another filed from an older version of the app that had something similar in it.

      I am going to go back and look that over as well as take a look at your input. I appreciate your insight.

      You have pointed me in the correct direction!

      ------------------------------
      Andrew
      andrew.fry25@gmail.com
      ------------------------------
      • BrandonDrake's avatar
        BrandonDrake
        Qrew Cadet
        Andrew, 

        No problem.  Mark's suggestion is a good one if you want to begin understanding Javascript.  That approach is cookie cutter js after the variable declaration, so it can be reused over and over by only changing the variable and will allow you to return to any record/form/report you place the button in without needing to build redirects.

        ------------------------------
        Brandon Drake
        JHI Group
        Monroeville OH
        ------------------------------