Forum Discussion

NathanMaubert's avatar
NathanMaubert
Qrew Trainee
8 months ago

Code Page - Redirect to Edit mode retains and redirects to code page on save

I have a code page that creates a (copied) record, manipulates a bunch of relationships and at the end of the code opens in the new record in edit mode. The issue is when the user hits native save button it redirects back to the code page rather than the table home page or even the record in view mode (ideal). Unfortunately the redirect causes another copy of the record to be created in a wonderful loop. Have tried to use replace vs href when building the new URL and rdr but it behaves the same. Have other similar code pages but this is the first time I have run into the issue. Any help would be great.



------------------------------
Nathan Maubert
------------------------------

5 Replies

  • You can try and interact/play with the browser history using window.history.pushState but in my experience it's a little inconsistent and if a user keeps clicking back then they still might get back. My suggestion would be to actually modify the code page and before you do anything check to see if that record has already been processed like checking a box for 'copied' on the original record. Another option is to provide a submission screen where they user can cancel out to cancel (like a confirm/submit & cancel buttons page instead of having the code page automatically process).

    \In the first example where you check to see if you should copy - you can instead just redirect them to the home page since they've already processed that entry. 



    ------------------------------
    Chayce Duncan
    ------------------------------
    • NathanMaubert's avatar
      NathanMaubert
      Qrew Trainee

      Unfortunately the record is a template project and could be copied several times over. I am wondering if I can open the code page in a pop-up and on completion close and then refresh the original page or redirect it to the edit record form. Just not sure how or if that would work.



      ------------------------------
      Nathan Maubert
      ------------------------------
      • ChayceDuncan's avatar
        ChayceDuncan
        Qrew Captain

        You could do a pop up using the following syntax: 

        "<a class='Vibrant Success OpenAsPopup' data-height=350 data-width=500 data-refresh=true href=\""& url here &"\" >Copy</a>"

        That will open up your code page and when the user clicks to close it, either with button or just closing the window QB will refresh the current page. 

        You could still go with a confirmation process in the code page that says 'confirm copy' or cancel so that the copy is not immediate if they land back there mistakenly.



        ------------------------------
        Chayce Duncan
        ------------------------------