Multiple Document - Rename

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
TonyDuke
Posts: 71
Joined: Mon Sep 11, 2017

15 May 2018

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 1749 times
I can't see where I am going wrong...

Thanks

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

15 May 2018

Dear Tony,
Which version of SharePoint are you using here?
Cheers

User avatar
TonyDuke
Posts: 71
Joined: Mon Sep 11, 2017

15 May 2018

Hi Nikita

We are using SP Online.

Thanks

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

16 May 2018

Dear Tony,
Try to remove the last listItem.update(); - it might be causing an issue here as you don't need it.
Cheers

User avatar
TonyDuke
Posts: 71
Joined: Mon Sep 11, 2017

16 May 2018

Hi Nikita,

This has resolved the issue...

Thanks

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests