Discussions

Expand all | Collapse all

Embedded button: URL Syntax

  • 1.  Embedded button: URL Syntax

    Posted 01-22-2020 13:41
    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
    ------------------------------


  • 2.  RE: Embedded button: URL Syntax

    Posted 01-22-2020 15:01
    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
    ------------------------------



  • 3.  RE: Embedded button: URL Syntax

    Posted 01-22-2020 15:06
    .. 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
    ------------------------------



  • 4.  RE: Embedded button: URL Syntax

    Posted 01-22-2020 15:25
    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
    ------------------------------



  • 5.  RE: Embedded button: URL Syntax

    Posted 01-22-2020 15:40
    Mark, thanks for the code, it worked great!

    Is it possible to have the re-direct take me back to the same tab I was on initially?

    ------------------------------
    Andrew
    andrew.fry25@gmail.com
    ------------------------------



  • 6.  RE: Embedded button: URL Syntax

    Posted 01-22-2020 16:01
    So far, no one on this Forum knows how to redirect to a particular tab.  At least not remotely natively with simple code.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------



  • 7.  RE: Embedded button: URL Syntax

    Posted 01-22-2020 16:10
    I do not believe that they will turn off javascript as it will break thousand of apps.  But I think that they will give the IT manager at your company the ability to tun off javascript as Quick Base cannot guarantee security if it is allowed.

    Quick Base does plan to introduce "New Forms" - when who knows maybe they will announce or even demo at EMPOWER.  My guess is that new forms will not allow javascript, but old forms will be supported forever.

    In the case of this refresh javascript, the alternative is that rdr syntax.  So theoretical worst case is that Quick base gives yuo a heads up that they will be block javascript in a year, presumably they will give us a tool to identify the fields with javascript, and then we will have to convert the fields.

    Meanwhile I continue to use that javascript refresh for now until it becomes clearer.

    I believe that Quick Base Product Managers see the need to be able to execute an API and refresh the page.  maybe they will give us a build in toggle setting on the field property to do that.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------



  • 8.  RE: Embedded button: URL Syntax

    Posted 01-22-2020 15:10
    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
    ------------------------------



  • 9.  RE: Embedded button: URL Syntax

    Posted 01-22-2020 15:19
    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
    ------------------------------



  • 10.  RE: Embedded button: URL Syntax

    Posted 01-22-2020 15:34
    Brandon,

    So I tried to adapt what you recommended to my situation. I am now getting a different error. The child record is still being updated correctly, but I am just not being taken back to the parent record.

    The error message I get is stating that the child record cannot be found. Yet the child record was updated .... ????
    Job is the child record.


    Here is the updated code I am using:

    URLRoot() & "db/" & Dbid()
    & "?act=API_EDITRecord&rid=" & [Job ID#]
    & "&_fid_177=" & Now()
    & "&_fid_178=" & UserToName(User(), "FF")
    & "&rdr=" & Dbid()& URLEncode("?a=er&rid="&[Work Order ID#])

    Just to be clear, this is a URL formula field in the child table. It is in a report whis is embedded in the parent table form. I am clicking the button from within the parent table form. I am not sure if that was clear from my original posts.

    Looking at the code, would it make any difference if it was the following:

    URLRoot() & "db/" &  [_DBID_JOBS]
    & "?act=API_EDITRecord&rid=" & [Job ID#]
    & "&_fid_177=" & Now()
    & "&_fid_178=" & UserToName(User(), "FF")
    & "&rdr=" & Dbid()& URLEncode("?a=er&rid="&[Work Order ID#])

    I appreciate you walking me through this.

    ------------------------------
    Andrew
    andrew.fry25@gmail.com
    ------------------------------



  • 11.  RE: Embedded button: URL Syntax

    Posted 01-23-2020 07:43
    Hello Andrew, 

    If the JS works best, that is the better solution per your conversations with Mark.  But to clarify on the redirect, I do not know exactly how your button is set up, so it may be clearer to explicitly define the DBID's you need to access using [_DBID_TableName] instead of DBID() for the API and the redirect and then replace the "rid" with "key" if you are not using the default Record ID# as the primary key.  This should fix the issue and take you back to editing the parent record.

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



  • 12.  RE: Embedded button: URL Syntax

    Posted 01-23-2020 09:04

    Brandon,

    Thanks for the info. Yes, I will be planning to use the JS. I am just curious about learning any other methods, including native ones, so that I can have that in my "belt of utilities". Thanks for the pointers!!



    ------------------------------
    Andrew
    andrew.fry25@gmail.com
    ------------------------------