Related Documents: Rename causes form to disappear
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
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Marshall,
Unfortunately, there is a lot of async requests going on here, especially on New Form. The ID is being updated, file is being renamed, there is no ID yet, so temp ID field must be filled. Unfortunately, not sure it can be avoided, as Related Items control has its own JS, which does get messed up.
Edit Form shouldn't have this issue, so I recommend not using Related Docs on New Form, if possible. For example, you can redirect users to Edit Form right after they save the New Form, and then offer to upload documents - https://plumsail.com/docs/forms-sp/how- ... ision.html
Unfortunately, there is a lot of async requests going on here, especially on New Form. The ID is being updated, file is being renamed, there is no ID yet, so temp ID field must be filled. Unfortunately, not sure it can be avoided, as Related Items control has its own JS, which does get messed up.
Edit Form shouldn't have this issue, so I recommend not using Related Docs on New Form, if possible. For example, you can redirect users to Edit Form right after they save the New Form, and then offer to upload documents - https://plumsail.com/docs/forms-sp/how- ... ision.html
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 7 guests