Hallo,
normally, when uploading a document, two additional fields should always be passed, provided they have been filled.
However, it happens more and more often that documents are uploaded but these two fields are not transferred.
One of the two fields is a mandatory field and should therefore always be selected. However, it is empty from time to time. How can I prevent this from happening? I suspect that it is due to the async function.
Here is my code.
var listOrLibrary = 'SPDataTable1';
var docLibraryTitle = 'Change request attachment';
var docLibraryId = '6487e86f-b9aa-472a-824d-7d2da7615032';
fd.control(listOrLibrary).$on('filesUploaded',
function(itemIds) {
//get document library by Title
var library = pnp.sp.web.lists.getByTitle(docLibraryTitle);var batch = pnp.sp.web.createBatch(); for(var i = 0; i < itemIds.length; i++){ //specify which fields to update and how var currentItem = pnp.sp.web.lists.getByTitle(docLibraryTitle).items.getById(itemIds[i]); currentItem.inBatch(batch).update({ Data: fd.field('Attachments_x0020_document_x0020').value, Description0: fd.field('Description').value }); } batch.execute().then(function(){ fd.control(listOrLibrary).refresh(); }); });