Forum Discussion

Hongkunliang's avatar
Hongkunliang
Qrew Cadet
18 days ago
Solved

Button: save the new record and edit the new record

Hi, 

From the previous post (Add Save and Keep Working Button on form for a new record ), Hunter provided a wonderful solution to save the new record.

If going further, is it possible to edit the new record within the same URL? I tried  the following, but got the error message "Missing "rid" parameter"

"URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=%%rid%%"

&"&_fid_20="&URLEncode("Yes");

My intention is to use one button instead of two buttons to provide the function:

(1) save the current new record (2) edit this new record. 

Any suggestion?  Thanks in advance!

  • Hi Mike,

    Thanks for your hint.  I made it works by moving the RID out the URLEncode.

    Here is the final code:

    var text RID = If([Record ID#] > 0, ToText([Record ID#]), "%%RID%%");
    var Text edit=URLRoot() & "db/" & Dbid() &
    "?act=API_EditRecord&rid="&$RID
    &"&_fid_20="&URLEncode("Yes");

    var text reDirect =
    URLRoot() & Dbid()?act=er&rid=";

    var Text URL=$Edit
    &  "&rdr=" & URLEncode($reDirect)& $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:200px; text-align: center; text-shadow: none; border: 2px solid #0863f5; font-size: 16px \"href='"
    & $URL
    & "'>Issue Announcement</a>"

6 Replies

  • try this

    var text RID = If([Record ID#] > 0, ToText([Record ID#]), "%%RID%%");
    var Text edit=URLRoot() & "db/" & Dbid() &
    "?act=API_EditRecord&rid="&$RID
    &"&_fid_20="&URLEncode("Yes");

    var text reDirectWithoutRID =
    URLRoot() & Dbid()?act=er&rid=";

    var Text URL=$Edit
    &  "&rdr=" & URLEncode($reDirectWithoutRID) & $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:200px; text-align: center; text-shadow: none; border: 2px solid #0863f5; font-size: 16px \"href='"
    & $URL
    & "'>Issue Announcement</a>"

    • Hongkunliang's avatar
      Hongkunliang
      Qrew Cadet

      Hi Mark, thanks for the response!  I think we got the same answer. 

  • Hi Mike,

    Thanks for your hint.  I made it works by moving the RID out the URLEncode.

    Here is the final code:

    var text RID = If([Record ID#] > 0, ToText([Record ID#]), "%%RID%%");
    var Text edit=URLRoot() & "db/" & Dbid() &
    "?act=API_EditRecord&rid="&$RID
    &"&_fid_20="&URLEncode("Yes");

    var text reDirect =
    URLRoot() & Dbid()?act=er&rid=";

    var Text URL=$Edit
    &  "&rdr=" & URLEncode($reDirect)& $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:200px; text-align: center; text-shadow: none; border: 2px solid #0863f5; font-size: 16px \"href='"
    & $URL
    & "'>Issue Announcement</a>"

  • I am able to make it work.  However, if trying to redirect to the newly saved record:

    redirect =URLRoot() & "db/" & Dbid() & "?act=er&rid=%%rid%%;

    It giving an error message, seems the %%rid%% can only be used once?

    • MikeTamoush's avatar
      MikeTamoush
      Qrew Commander

      Can you post your entire code? The %%rid%% cannot be URLEncoded, so if somewhere in your code that redirect is URL encoded, that would cause it to fail. There are work arounds, but we would need to see the entire code.

      • Hongkunliang's avatar
        Hongkunliang
        Qrew Cadet

        Hi Mark,  I think you caught the point. The %%rid%% is used twice in the formula. 1st time is working, the 2nd time is URLEncoded  in the redirect and it fails.    Can't wait to see how to make it working.  Thanks again.

        Here is the code:

        var text RID = If([Record ID#] > 0, ToText([Record ID#]), "%%RID%%");
        var Text edit=URLRoot() & "db/" & Dbid() &
        "?act=API_EditRecord&rid="&$RID
        &"&_fid_20="&URLEncode("Yes");

        var text reDirect =
        URLRoot() & Dbid()?act=er&rid="&$RID;

        var Text URL=$Edit
        &  "&rdr=" & URLEncode($reDirect);

        "<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:200px; text-align: center; text-shadow: none; border: 2px solid #0863f5; font-size: 16px \"href='"
        & $URL
        & "'>Issue Announcement</a>"