Discussions

 View Only
Expand all | Collapse all

New functionaility %%rid%%

  • 1.  New functionaility %%rid%%

    Posted 06-01-2021 14:54
    Has anyone used the new feature that allows you to grab the record ID from a custom Rich Text button on an add record form? Ive used it once successfully, and now am completely stuck on why i cant get it to work again.

    In my code below I am trying to pass the new record ID to field 57 in my addcontract variable. (57 is a numeric field). But instead of the new RID it inserts 'id'. I've tried wrapping with URLEncode, no luck. Thoughts?

    var text AddContract = URLRoot() & "db/" & "brgdpr9fn?a=API_GenAddRecordForm"
    & "&_fid_12=" & URLEncode ([Related Vendor])
    & "&_fid_57=" & "%%rid%%";

    var text EditUserFocus =
    URLRoot() & "db/" & "bp8yr9i5s?a=API_EditRecord" &
    "&key=" & UserToEmail(User()) &
    "&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxx" &
    "&_fid_220=" & [Service Order - SO #] &
    "&_fid_224=" & [Related Service Order];

    "<a class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration:none; background: #4b7097; border-radius: 5px; color: #ffffff; display: inline-block; padding: 0px 0px 0px 0px; width:100px; text-align: center; text-shadow: none; border: 2px solid #030404; font-size: 12px \"href='"
    & $EditUserFocus
    & "&rdr=" & URLEncode($AddContract)
    & "'>Add Subcontract</a>"

    ------------------------------
    Mike Tamoush
    ------------------------------


  • 2.  RE: New functionaility %%rid%%

    Posted 06-02-2021 13:03
    Try this:

    var text RID = "%%rid%%";

    var text AddContract = URLRoot() & "db/" & "brgdpr9fn?a=API_GenAddRecordForm"
    & "&_fid_12=" & URLEncode ([Related Vendor])
    & "&_fid_57=";

    var text EditUserFocus =
    URLRoot() & "db/" & "bp8yr9i5s?a=API_EditRecord" &
    "&key=" & UserToEmail(User()) &
    "&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxx" &
    "&_fid_220=" & [Service Order - SO #] &
    "&_fid_224=" & [Related Service Order];

    "<a class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration:none; background: #4b7097; border-radius: 5px; color: #ffffff; display: inline-block; padding: 0px 0px 0px 0px; width:100px; text-align: center; text-shadow: none; border: 2px solid #030404; font-size: 12px \"href='"
    & $EditUserFocus
    & "&rdr=" & URLEncode($AddContract) & $RID
    & "'>Add Subcontract</a>"

    ------------------------------
    Brad Lemke
    ------------------------------



  • 3.  RE: New functionaility %%rid%%

    Posted 06-02-2021 15:00
    No luck, now it puts in nothing.

    ------------------------------
    Mike Tamoush
    ------------------------------



  • 4.  RE: New functionaility %%rid%%

    Posted 06-02-2021 15:14
    To explain what I did: the "%%rid%%" function fails when it is embedded inside a URLEncode(...).  Referencing it outside of the Encode won't break it, and typically makes it work perfectly for me in very similar scenarios (I use it in two places in my app).  It can be finicky and I'm still learning the nuances. 

    Does the URL of the page you're redirected to (the genaddrecordform) have any artifacts or anything that looks off?

    ------------------------------
    Brad Lemke
    ------------------------------



  • 5.  RE: New functionaility %%rid%%

    Posted 06-02-2021 15:18

    Interesting about it failing inside URLEncode.

    Nothing I can find particularly off. If I save the record, and then use 'Record ID' instead of %%rid%%, it works fine, but thats not really a surprise. 

    What kind of 'artifacts' are you thinking could cause havoc?



    ------------------------------
    Mike Tamoush
    ------------------------------



  • 6.  RE: New functionaility %%rid%%

    Posted 06-02-2021 15:22
    Oh wait. So I found what I thought was the issue. I had changed to a popup instead of savebefore navigating. I changed that back and now I have my original issue - it doesnt run any of the actions, it just refreshes the screen (what I was explaining in my other post).

    It's maddening lol.

    ------------------------------
    Mike Tamoush
    ------------------------------



  • 7.  RE: New functionaility %%rid%%

    Posted 06-02-2021 15:59
    Let me try to wrap my head around the process you're doing here, and I'm going to make a couple assumptions that I need you to confirm or correct:

    There's 3 tables being used here:
    Table A: the table that this button is built in and is where you are starting in this workflow.
    Table B: the User Focus table, referenced in the $EditUserFocus variable.
    Table C: the table and form that you're trying to land in after you hit the button in Table A, carrying over the newly created RID for Table A.

    Is this correct?

    ------------------------------
    Brad Lemke
    ------------------------------



  • 8.  RE: New functionaility %%rid%%

    Posted 06-02-2021 16:12
    Yes that is correct, but the key to it all is - I only have any of the troubles when table A (that I am starting the workflow from) is in Add Record Mode. If the record ID has been created, I can get everything to work properly.

    ------------------------------
    Mike Tamoush
    ------------------------------



  • 9.  RE: New functionaility %%rid%%

    Posted 06-02-2021 16:21
    Let's see if this works instead (cutting out the genaddrecordform in favor of a=nwr):


    var text RID = "%%rid%%";


    var text AddContract = URLRoot() & "db/" & "brgdpr9fn?a=nwr"
    & "&_fid_12=" & URLEncode ([Related Vendor])
    & "&_fid_57=";

    var text EditUserFocus =
    URLRoot() & "db/" & "bp8yr9i5s?a=API_EditRecord" &
    "&key=" & UserToEmail(User()) &
    "&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxx" &
    "&_fid_220=" & [Service Order - SO #] &
    "&_fid_224=" & [Related Service Order];

    "<a class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration:none; background: #4b7097; border-radius: 5px; color: #ffffff; display: inline-block; padding: 0px 0px 0px 0px; width:100px; text-align: center; text-shadow: none; border: 2px solid #030404; font-size: 12px \"href='"
    & $EditUserFocus
    & "&rdr=" & URLEncode($AddContract) & $RID
    & "'>Add Subcontract</a>"

    ------------------------------
    Brad Lemke
    ------------------------------



  • 10.  RE: New functionaility %%rid%%

    Posted 06-02-2021 16:32
    So, it didn't work, but it allowed me to try something interesting (which still doesn't make sense to me and only confirms my intial issue).

    The URL that produced was:
    https://sesgroup.quickbase.com/db/brgdpr9fn?a=nwr&_fid_12=0&_fid_57=

    Which left field 57 blank.
    I manually changed that URL to:
    https://sesgroup.quickbase.com/db/brgdpr9fn?a=nwr&_fid_12=0&_fid_57=%%rid%%

    Which put "id" in field 57. Hmmm...

    ------------------------------
    Mike Tamoush
    ------------------------------



  • 11.  RE: New functionaility %%rid%%

    Posted 06-02-2021 17:00
    That is odd.  The only other thing I do different in my app/formulas is I actually set up a global variable that I named [NewRID], containing just the pure text with no quotes: %%rid%%



    ------------------------------
    Brad Lemke
    ------------------------------



  • 12.  RE: New functionaility %%rid%%

    Posted 06-02-2021 17:28
    Thanks, Ill try that and get with customer support if needed. Appreciate your insight.

    ------------------------------
    Mike Tamoush
    ------------------------------



  • 13.  RE: New functionaility %%rid%%

    Posted 06-09-2021 17:16
    Make sure you make an edit on the add record, then press the button.  Otherwise, it will not work.  This has tripped me up twice now...

    ------------------------------
    Anne Murray
    ------------------------------



  • 14.  RE: New functionaility %%rid%%

    Posted 12-07-2021 10:52
    Edited by Mark Shnier (Your Quickbase Coach) 12-07-2021 10:56
    Just posting some code that worked. The goal was to add a record and return the user to the added record in Edit mode.

    var text RID = "%%rid%%";

    var text AddShipment = URLRoot() & "db/" & Dbid() & "?a=nwr";
    var text EditShipment = URLRoot() & "db/" & Dbid() & "?a=er&rid=" ;

    var text URL =
    $AddShipment
    & "&rdr=" & URLEncode($EditShipment) & $RID;


    "<a class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration:none; background: #4b7097; border-radius: 5px; color: #ffffff; display: inline-block; padding: 0px 0px 0px 0px; width:100px; text-align: center; text-shadow: none; border: 2px solid #030404; font-size: 12px \"href='"
    & $URL
    & "'>Save and Display in Edit Mode</a>"

    NOTE: The %%RID%% does not seem to like being URLEncoded.

    The use case might be to land the user on a saved record so that the Report Link fields would immediately populate.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 15.  RE: New functionaility %%rid%%

    Posted 12-07-2021 11:43
    Thanks Mark. I bet that my original issue was that it was, in the end, URL Endcoded. I thought it wasn't because it wasn't URLEncoded in my variable, but looking back I see it ended up inside a URLEncode anyways...!

    ------------------------------
    Mike Tamoush
    ------------------------------