Forum Discussion

HarrisonSmith's avatar
HarrisonSmith
Qrew Trainee
3 years ago

Add Child Record, then edit that child record, then redirect to edit form of child record

I feel like this should be easy but I'm drawing a blank. I have a situation where, when a child record (media) gets created via button, the user has to save the record after making their changes, then edit it again to update 1 last field. This is because that last field needs to be populated with a location path that contains the record ID of the child media record, which doesn't exist yet when they click the button to add the media. So it just creates a few extra clicks that shouldn't really be necessary. 
So I'm trying to tweak the button to create the media from the parent (request), then edit that same media record by populating a text field with "some string" & the newly created RID for this child media record. Lastly, after adding & editing the record, I'll have it redirect to the edit form of the media so the user can make their edits as necessary.

------------------------------
Harrison Smith
------------------------------
    • HarrisonSmith's avatar
      HarrisonSmith
      Qrew Trainee
      Thanks Mark, knew you'd have a quick response. Unfortunately I'm getting an error saying "sorry, there is no record in this application table with the record identifier (rid) of "0".

      This is the code for my button as it stands now:

      var text rid = "%%rid%%";
      var text Token = my app token;
      var text CreateMedia = URLRoot() & "db/" & [_DBID_MEDIA] & "?a=API_GenAddRecordForm&apptoken=" & $Token & "&_fid_7=" & URLEncode([Record ID#]);
      var text UpdateMedia = URLRoot() & "db/" & [_DBID_MEDIA] & "?a=API_EditRecord&apptoken=" & $Token & "&RID=" & $rid & "&_fid_14=testingAddRID" & $rid;
      var text URL = $CreateMedia & "&rdr=" & URLEncode($UpdateMedia) & $RID;


      "<a class='Vibrant Primary SaveBeforeNavigating' data-replaceRid=true href='" & $url & "'>Add Matter, Update New Matter, Return to Edit New Matter</a>"

      ------------------------------
      Harrison Smith
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        What you want to do is to ADD Media totally normally.  Use the usual add child button that Quickbase created for you, but without the "&z=Rurl() part.

        Then create a button to on the Media record to show in ADD and Edit mode which you will use instead of the native green SAVE button.  Call it like "Save and Continue Editing".

        var text RID = IF([Record ID#]>0, [Record ID#], %%RID%%);

        var text URL = URLRoot() & "db/" & [_DBID_MEDIA] & "?a=er&rid=" & $RID;


        "<a class='Vibrant Primary SaveBeforeNavigating' data-replaceRid=true href='" & $URL & "'>Save and Continue Editing"</a>"



        ------------------------------
        Mark Shnier (YQC)
        mark.shnier@gmail.com
        ------------------------------