How to remember in a form field the last data entry of the previous submission

  • 23 March 2017
  • 3 replies
  • 33 views

I have a form with several fields that need to have the same data of the last form submission.  What is the best way for a field to have the same last data from the previous entry?  This is for multiple entries made to the same area,  owner, date etc.


3 replies

Badge +4

Mike Rigau‌,

I believe the most easy way to accomplish this would be to leverage javascript and CSOM in order to copy an item and use whatever form field values to populate the new item. I have a button 'Copy' that on click calls the function copyItem();

The javascript that I use is as follows:

function copyItem() {

// Nintex Variable
    var oList = clientContext.get_web().get_lists().getByTitle('List Name');
        
    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = oList.addItem(itemCreateInfo);

// This is where you would set your item values

// They would look as follows

oListItem.setItem('List_column_name', 'value to be set'); - DO NOT COPY these values, use your own. - you can find the exact column name by opening your list settings and then clicking the column you want to edit. In the URI that opens in your browser, there will be a query parameter at the end, like Field=Title, Title is the name of the column.

oListItem.setItem('Another_column', 'value to be set'); - If you have placed a javascript variable id on your form fields, you can reference the value with NWF$('#' + javascriptid).val(); where javascriptid is what you've designated for that form field.


    oListItem.update();

    clientContext.load(oListItem);       
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

}

function onQuerySucceeded() {
alert('Your Event has been copied, and will open upon clicking OK');
// Nintex Variable
url = 'Site URL/Lists/List Name/DispForm.aspx?ID=' + oListItem.get_id();
window.location.href = url;
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '
' + args.get_stackTrace());

}

Whenever you see // Nintex Variable the blue text references a Nintex keyword variable found in the right pane of your settings when in the custom javascript field.

If you need more help, please let me know and I'll be glad to provide what assistance I can.

Thanks,

-Trang

Badge +8

Hi ‌,

Nintex Mobile has such a functionality: Sent and copied as draft

Perhaps this could be useful for you.

Cheers,

Rick

Userlevel 7
Badge +17

‌ have you found solution for your question? Is any from the replies helpful enough to be marked as correct?

Regards,

Tomasz

Reply