Discussions

 View Only
Expand all | Collapse all

Adding code to formula - URL - button to redisplay current page once a record is edited by pressing approval button

  • 1.  Adding code to formula - URL - button to redisplay current page once a record is edited by pressing approval button

    Posted 05-15-2021 16:50
    Edited by Peter Krasznekewicz 05-17-2021 15:40


         I am aiming to add an "approval" button to check a box in a field that can be used on reports for a dashboard. Once the button is pressed I just want it to redisplay the same page (this is the part I am not sure how to add). I realize I need to tell the formula to redisplay the same page but I am not sure how to proceed on that using 

         Below is the code I am using to edit the record and check the box ("my token" is my API token in the actual code).

    Code

    URLRoot() & "db/" & Dbid() & "?act=API_EditRecord"& "&rid=" & URLEncode ([Record ID#])&
    "&_fid_Final Approval=1" & "&apptoken=" & "my token"


    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>0</errcode>
    <errtext>No error</errtext>
    <rid>1139</rid>
    <num_fields_changed>0</num_fields_changed>
    <update_id>1621033392832</update_id>
    </qdbapi>


    Thank you in advance for any help. 


    ------------------------------
    Peter Krasznekewicz
    ------------------------------


  • 2.  RE: Adding code to formula - URL - button to redisplay current page once a record is edited by pressing approval button

    Posted 05-15-2021 18:18
    Right, so after you do an API call you need to land the user on a report or a record (or a page refresh) to suppress that XML response.  So that means that you need to chain two steps successively.

    The generic form to do two successive actions is this when written using formula variables (which i highly recommnend for formula readability).

    $URLONE
    & "&rdr=" & URLEncode($URLTWO)

    The Refresh page which is the last step will look like this.

    URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl())

    so..

    Putting it all together will look like this

    var text Approve = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord"& "&rid=" & URLEncode ([Record ID#])&
    "&_fid_Final Approval=1" & "&apptoken=" & "my token";

    var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

    $Approve
    & "&rdr=" & URLEncode($RefreshPage)

    My last comment is that you have specified for field to edit using the field name.  That will work, but if you chamnge the field name it will break.  So I always refer to the field ID#

    var text Approve = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord"& "&rid=" & URLEncode ([Record ID#])&
    "&_fid_99=1" & "&apptoken=" & "my token";

    var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

    $Approve
    & "&rdr=" & URLEncode($RefreshPage)












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



  • 3.  RE: Adding code to formula - URL - button to redisplay current page once a record is edited by pressing approval button

    Posted 05-17-2021 15:42
    Mark, Thank you very much for your help. Button is now working as it should I edited the Field ID to display field number as well. 


    ------------------------------
    Peter Krasznekewicz
    ------------------------------