Duplicate row of list data in SPO form

I've got a form which has a linked list (linked by lookup field Contract). I've added the duplicate row JS and it duplicates what I've put in fieldsToCopy, except for the lookup field Contract.

// Duplicate row Items & Adjustment
fieldsToCopy = ['Contract', 'Start_x0020_Date', 'End_x0020_Date', 'Title', 'EquipmentManufacturer', 'Equipment_x0020_Type', 'Current_x0020_Equipment_x0020_Lo', 'REM_x0020_ID'];
fd.spRendered(function() {
//new button
var duplicateButton = {
text: 'Duplicate row',
class: 'btn-secondary',
visible: false,
icon: 'Copy',
iconType: 0,
click: function() {
//get list from List or Library
var listURL = fd.control('SPDataTable7').listRootFolder;
//get item IDs of selected item
var itemID = fd.control('SPDataTable7').selectedItems[0].ID;
var items = pnp.sp.web.getList(listURL).items;
//retrieve all information about selected item
//create a copy
var copy = {};
//go through fields and copy each one
fieldsToCopy.forEach(function(field) {
//copy regular fields
copy[field] = item[field];
//add new item based on copy
duplicateButton.visible = false;

fd.control('SPDataTable7').ready(function(dt) {
    //dt parameter is the same as fd.control('SPDataTable0')

    dt.$watch('selectedItems', function(items) {
        duplicateButton.visible = items && items.length == 1 ;


Hello @Nicola_01,

You must add Id suffix to the end of the lookup field name. For instance, if the Internal Lookup field name is Project, the property name that hold the lookup value ID is ProjectId.

1 Like

Thankyou soooooo much, I knew it would be something simple!

1 Like