Skip to main content
Solved

Button: save the new record and edit the new record

  • April 11, 2024
  • 0 replies
  • 613 views

Forum|alt.badge.img+6

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!

Best answer by Hongkunliang

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

This topic has been closed for replies.

Forum|alt.badge.img+6
  • Author
  • Registered
  • April 11, 2024

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?


Forum|alt.badge.img+6
  • Author
  • Registered
  • Answer
  • April 16, 2024

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


MarkShnierYou
Forum|alt.badge.img+24

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