Copying List Item to Create New Item

Looking to create a clone button on a form so when someone clicks it, it will open up a new form (same list) that is pre populated with values from the parent item. I can do this with a workflow but it'll save it and ideally I want the user to be able to make edits before hitting save for the first time (since I have workflows that trigger on creation that I don't want to go off prematurely).

I seem to recall there being a relatively simple solution to do this (as I did it once before opting for a workflow for a previous case) but I can't recall or find it.

Hello @teddy0bear,

You can save the data of a form to local storage and then populate a new form with it.

This is the code sample for the button click property:

//save form data to the local storage
localStorage.setItem('FormData', JSON.stringify(fd.data()));

//redirect to the new form
window.location.href = 'New Form URL';

And you need to add this code to the New form:

fd.spRendered(function() {
    var formData = localStorage.getItem('FormData')
    //check whether the local storgae has form data
    if (formData) {
        //populate form
        fd.data(JSON.parse(formData));
        //clear local storage 
        localStorage.removeItem('FormData');
    }
});

Thank you! That's what I was looking for :slight_smile: