//Use Internal Names of your fields fieldsToCopy = ['Title', 'MondayNotes', 'TuesdayNotes', 'WednesdayNotes', 'ThursdayNotes', 'FridayNotes', 'Position', 'Region']; 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('SPDataTable1').listRootFolder; //get item IDs of selected item var itemID = fd.control('SPDataTable1').selectedItems[0].ID; var items = pnp.sp.web.getList(listURL).items; //retrieve all information about selected item items.getById(itemID) .get().then(function(item){ //create a copy var copy = {}; //go through fields and copy each one fieldsToCopy.forEach(function(field) { //copy regular fields if(item[field]){ copy[field] = item[field]; } //copy more complex fields - Person/Lookup else if(item[field + 'Id']){ copy[field + 'Id'] = item[field + 'Id']; } }); //add new item based on copy items.add(copy).then(function(result){ fd.control('SPDataTable1').refresh(); duplicateButton.visible = false; }); }); } } fd.control('SPDataTable1').ready().then(function(dt) { //dt parameter is the same as fd.control('SPDataTable0') dt.buttons.push(duplicateButton); dt.$watch('selectedItems', function(items) { duplicateButton.visible = items && items.length == 1 ; }); }); }); window.fd = fd; fd.spRendered(function() { fd.field('Name').$on('change', function () { fd.field('Title').value = fd.field('Name').value.DisplayText; }); }); fd.spRendered(function() { //executes the below steps on field change fd.field('Name').$on('change', function(value) { //gets manager name of the selected user pnp.sp.profiles.getPropertiesFor(fd.field("Name").value.Key).then(function(result) { var props = result.UserProfileProperties; for(var i = 0; i < props.length; i++){ if(props[i].Key == "Manager"){ fd.field("Supervisor").value = props[i].Value; break; } } }); }); window.$ = $; window.define = null; fd.spRendered(function() { $.getScript('https://site.sharepoint.com/sites/StaffDevelopment/SiteAssets/moment-with-locales.js') .then(function() { return $.getScript('https://site.sharepoint.com/sites/StaffDevelopment/SiteAssets/moment-with-locales.js')}) .then(function() { var m = moment(); var date = moment(fd.field('OrientationStartDate').value); var newDate = date.add(2, 'days').calendar(); fd.field('Productivity_x0020_Prediction').value = newDate; }) });