Related Documents: Rename causes form to disappear
Posted: 29 Mar 2019
Hello
I am trying to rename a related document as it is uploaded. On the edit form, the document is uploaded and renamed as required.
On the new form for a new list item, when a document is dragged on to the form and the rename script activates the document is renamed but disappears from the form. Looking at the document library, the document exists with its new name. If you save the parent form, the Id field in the document library is populated with the parent list item Id.
If I remove the line that renames the document, the upload works as designed.
Javascript for New form:
fd.updateDroppedDocuments($('.related-docs'), {
ParentId: '{CurrentItem}'
});
fd.updateDroppedDocuments($('.related-docs'), function (listItem) {
var cntr = 1;
var dir = listItem.get_item('FileDirRef');
var fileName = 'Form-' + listItem.get_fieldValues().FileLeafRef;
listItem.set_item('Project', 'ABC001');
listItem.update();
listItem.get_file().moveTo(dir + '/' + fileName);
});
Why is the renamed document disappearing from the new list item form?
I am using SP Forms 3.1.4
Thanks
I am trying to rename a related document as it is uploaded. On the edit form, the document is uploaded and renamed as required.
On the new form for a new list item, when a document is dragged on to the form and the rename script activates the document is renamed but disappears from the form. Looking at the document library, the document exists with its new name. If you save the parent form, the Id field in the document library is populated with the parent list item Id.
If I remove the line that renames the document, the upload works as designed.
Javascript for New form:
fd.updateDroppedDocuments($('.related-docs'), {
ParentId: '{CurrentItem}'
});
fd.updateDroppedDocuments($('.related-docs'), function (listItem) {
var cntr = 1;
var dir = listItem.get_item('FileDirRef');
var fileName = 'Form-' + listItem.get_fieldValues().FileLeafRef;
listItem.set_item('Project', 'ABC001');
listItem.update();
listItem.get_file().moveTo(dir + '/' + fileName);
});
Why is the renamed document disappearing from the new list item form?
I am using SP Forms 3.1.4
Thanks