ToddM
24 days agoQrew Cadet
Save and New Button on Legacy form
I'm trying to build what I thought would be a simple button for saving the current child record and adding a new one to the same parent record. I'm essentially just trying to duplicate the native Sav...
- 23 days ago
I did it with a code page like this:
Formula on child:
var text parentValue = ToText([Related Record]); //update to your field var text childDb = "abc123xyz"; //update to your child dbid var number parentFid = 7; //update to related parent fid for related field above var text url = URLRoot() & "db/" & $childDb & "?a=API_GenAddRecordForm" & "&_fid_" & ToText($parentFid) & "=" & URLEncode($parentValue) & "&NextURL=" & URLEncode( URLRoot() & "db/" & Dbid() & "?a=dbpage&pageID=73" & //replace 73 with your code page ID "&db=" & $childDb & "&fid=" & ToText($parentFid) & "&parent=" & URLEncode($parentValue) ); "<a class='Vibrant Success SaveBeforeNavigating' href='" & $url & "'>Save and New</a>"Create a code page:
<!DOCTYPE html> <html> <head> <script> const p = new URLSearchParams(window.location.search); const db = p.get("db"); const fid = p.get("fid"); const parent = p.get("parent"); window.location = location.origin + "/db/" + db + "?a=API_GenAddRecordForm" + "&_fid_" + fid + "=" + encodeURIComponent(parent) + "&NextURL=" + encodeURIComponent(window.location.href); </script> </head> <body></body> </html>Button triggers the save and redirects to code page with context in the URL, and code page redirects back to record using the context.