Page 1 of 1

Multiple Document - Rename

Posted: 15 May 2018
by TonyDuke
Good Afternoon,

I have a Related Document Control setup on a Display Form to allow users to drag and drop new documents, with script to set the metadata and also to rename the document. The functionality seems to work fine if a user only drops one document onto the Related Document Control, however, if the user then attempts to drop another they are presented with a message stating -"There is an upload is in progress. Please wait until the current upload has finished." with an option to close the message. The only option is for the user to refresh the page, the Document will then show and all seems to be ok.
If a user drops multiple items onto the Control only the first item gets the meta data set against it and renamed, and again the same message as before is displayed if a user attempts to add more documents.

My code is

Code: Select all

// Add Parent ID to uploaded email for retrieval
fd.updateDroppedDocuments($('.documentUploadRICssClass'), {
  Company_x0020_Name: '{CurrentItem}'
});


// Update Uploaded Document for Relevant fields
fd.updateDroppedDocuments($('.documentUploadRICssClass'), function(listItem) {
	//get the values from the Form fields:
	var contactName = getPrimaryContactName();
	var addressName = getAddressName();
	var currentName = listItem.get_fieldValues().FileLeafRef;
	var prefix = Date.now() / 1000 | 0;
    	var newName = prefix + currentName;
	var documentType = $("#DocumentType option:selected").val();
	var newFileName = listItem.get_item('FileDirRef') + '/' + newName;
	//set the values on uploaded document:
	listItem.set_item('Contact_x0020_Name', contactName);
	listItem.set_item('Address_x0020_Name', addressName);
	listItem.set_item('Title', currentName);
	listItem.set_item('Document_x0020_Type', documentType);
	listItem.update();
  	listItem.get_file().moveTo(newFileName);
	listItem.update();
});
I have checked the console and there does appear to be an error message following dropping a document, I have attached a screenshot...
Capture.PNG
Capture.PNG (7.07 KiB) Viewed 1751 times
I can't see where I am going wrong...

Thanks

Re: Multiple Document - Rename

Posted: 15 May 2018
by Nikita Kurguzov
Dear Tony,
Which version of SharePoint are you using here?

Re: Multiple Document - Rename

Posted: 15 May 2018
by TonyDuke
Hi Nikita

We are using SP Online.

Thanks

Re: Multiple Document - Rename

Posted: 16 May 2018
by Nikita Kurguzov
Dear Tony,
Try to remove the last listItem.update(); - it might be causing an issue here as you don't need it.

Re: Multiple Document - Rename

Posted: 16 May 2018
by TonyDuke
Hi Nikita,

This has resolved the issue...

Thanks