Forum Discussion

PeterKrasznekew's avatar
PeterKrasznekew
Qrew Trainee
4 years ago

Button to edit existing record and create / copy all information to new record

I currently am using an "Approve" button that is functioning to change one field in an existing record, however, I would love for that one button to not only edit the existing record but also create a new record with mostly the same information as the existing record minus a few fields one of which will need to be changed as the button is pressed and the others can be left blank if they vary from the existing form. 

When using the API_AddRecord is there a way to tell that record to pull field information off the current record and populate it on the new record? 

Current button code:

URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&_fid_26=Approved" & "&rdr="&URLEncode(URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl())

Currently stuck on new button code:

URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
& "&_fid_26=Approved"
& "&rdr="
& URLEncode(URLEncode( URLRoot() & "db/"& Dbid() & "?a=API_AddRecord"

(Fields here)


"&rdr="&URLEncode(URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl())


Thank you in advanced for any assistance or help!

------------------------------
Peter Krasznekewicz
------------------------------

3 Replies

  • Are you looking to actually create a new record or are you looking up to to put up and Add Record form with fields pre-filled for the user to complete the editing of it and save it for the first time?

    If you were looking to actually create the record are you looking to land the user on the record and edit mode or in View Mode.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    mark.shnier@gmail.com
    ------------------------------
    • PeterKrasznekew's avatar
      PeterKrasznekew
      Qrew Trainee
      Hi Mark, 
        
          Thank you for your response.

          Let me try walking through our process to see if it makes a bit more sense. 

          1. User fills out a form to create a record (Record 1) with field "Type" as "x"

          2. Record 1 is routed for approval

          3. Once Record 1 is approved...
                     a. Field 26 in Record 1 is set to approved (currently how approved button is functioning)
                     b. Record 2 is created with Fields 1-10 being the same as in Record 1 but field "type" is left blank to                          be filled in by user

       Since the goal is to have the "approved" button trigger the creation of the new record, it just needs to refresh the current page where the approved button was clicked as the new record will not need to be viewed/edited by the user who will approve Record 1. 

      Thank you. 


      ------------------------------
      Peter Krasznekewicz
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        See if this helps.

        The generic nesting syntax do do successive URL calls is this.

        $URLONE
        & "&rdr=" & URLEncode($URLTWO)
        & URLEncode("&rdr=" & URLEncode($URLTHREE))
        & URLEncode(URLEncode("&rdr=" & URLEncode($URLFOUR)))
        & URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLFIVE))))
        & URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSIX)))))
        & URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSEVEN))))))

        , and you just slice off as much of the salami as you need.

        In your case you need to do three URL calls in sequence.

        1. Update the record you are on.
        2. Create a new record.
        3. Land the user on the original page refreshed in part to suppress the XML response from  the previous step.

        So you will define Three formula variables.

        var text FlagAsApproved = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&_fid_26=Approved";

        var text CreateNewRecord = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord"
        & "&_fid_10=" & URLEncode([field name for fid 10]]
        & "&_fid_11=" & URLEncode([field name for fid 11]]
        & "&_fid_12=" & URLEncode([field name for fid 12]]
        & "&_fid_13=" & URLEncode([field name for fid 10]];

        var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

        Then we slice off three slices formula above and put in the proper formula variable names.


        $FlagAsApproved
        & "&rdr=" & URLEncode($CreateNewRecord)
        & URLEncode("&rdr=" & URLEncode($RefreshPage)

        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        .... the reason  that this part below s URLEncoded is only if you are putting values into this URL string that you are building which are not A-Z or 0-1 plain characters.  The "click" needs to travel though the whole internet and the internet does not handle spaces or nor many other special characters, so they need to be URLEncoded if there is any risk that the contents will have spaces or special characters.


        & "&_fid_10=" & URLEncode([field name for fid 10]]
        & "&_fid_11=" & URLEncode([field name for fid 11]]
        & "&_fid_12=" & URLEncode([field name for fid 12]]
        & "&_fid_13=" & URLEncode([field name for fid 10]];

        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        mark.shnier@gmail.com
        ------------------------------