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.
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
Nintex Mobile has such a functionality: Sent and copied as draft
Perhaps this could be useful for you.
Cheers,
Rick
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.