Forum Discussion

MichaelTamoush's avatar
MichaelTamoush
Qrew Captain
3 years ago

New functionaility %%rid%%

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
------------------------------

14 Replies

  • BradLemke's avatar
    BradLemke
    Qrew Assistant Captain
    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
    ------------------------------
    • MichaelTamoush's avatar
      MichaelTamoush
      Qrew Captain
      No luck, now it puts in nothing.

      ------------------------------
      Mike Tamoush
      ------------------------------
      • BradLemke's avatar
        BradLemke
        Qrew Assistant Captain
        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
        ------------------------------