Forum Discussion

hiker85's avatar
hiker85
Qrew Trainee
25 days ago

Adding child records that rely on lookups in new forms

I have a new-style form that displays pages as steps. The user clicks the button (Formula URL) under step #3 to add a child record. Once they save that record, they're redirected back to the form, but on step #1. How do I bring the user back to the last step they were on?

URLRoot() & "db/" & [_DBID_TABLE_ALIAS_HERE] & "?a=API_GenAddRecordForm&_fid_6=" & URLEncode ([Record ID#])& "&z=" & Rurl()

The app uses New Grid Reports. I tried having the user add records in-line, however those rely on lookups to the parent and they won't save, saying that the lookup value is not set.

I created a new Formula URL button to redirect back to that specific tab. It works when editing/viewing records but not when adding.

URLRoot() & "db/" & [_DBID_TABLE_ALIAS_HERE] & "?a=API_GenAddRecordForm&_fid_6=" & URLEncode ([Record ID#]) & "&NextURL=" & URLEncode(URLRoot() & "db/" & Dbid() & "/form?a=er&rid=" & [Record ID#] & "&page=2")




3 Replies

  • Denin's avatar
    Denin
    Qrew Captain

    I was able to do it like this:

    Create a code page (copy and paste code below), change page 2 to whatever page or tab you need:

    <script>
    const params = new URLSearchParams(window.location.search);
    
    const parentRid = params.get("parentrid");
    const parentDbid = params.get("parentdbid");
    
    window.location.href =
      "/db/" + parentDbid +
      "?a=er&rid=" + parentRid +
      "&page=2";
    </script>

     

    And then change your formula to this:

    URLRoot() & "db/" & [_DBID_TABLE_ALIAS]
    & "?a=API_GenAddRecordForm"
    & "&_fid_6=" & [Record ID#]
    & "&nexturl="
    & URLEncode(
        URLRoot() & "db/" & Dbid()
        & "?a=dbpage&pageID=72"  //Change 72 to the ID of the code page you created
        & "&parentrid=" & [Record ID#]
        & "&parentdbid=" & Dbid()
    )

     

     

  • I would have thought that the savebeforenavigating Rich Text formula would work, but it doe not seem to work on New Style forms.

     

  • Roy-Wanyoike's avatar
    Roy-Wanyoike
    Qrew Assistant Captain

    Hey try this by use of a well-crafted Formula-URL button on the parent record’s multi-page form. When the user clicks the button on Step #3 to add a child record, the formula should open the Add Record form for the child table and pass the parent Record ID# through the reference field. Most importantly, use the rdr (redirect) parameter to send the user back to the exact same page they were on after saving the child record. Here would be the formula structure: 

    ```

    URLRoot() & "db/" & [_DBID_CHILD_TABLE] & "?a=API_GenAddRecordForm" &

    "&_fid_XX=" & URLEncode([Record ID#]) &

    "&rdr=" & URLEncode(

    URLRoot() & "db/" & Dbid() & "?a=er&rid=" & [Record ID#] & "&page=3"

    )
    ```
    This approach keeps the user experience smooth: they stay in the context of the wizard-style form and return to the step they were working on, instead of being sent back to Step 1. Test the formula thoroughly, and consider creating a helper formula field to store the redirect URL if you need to reuse it across multiple buttons.