Page 1 of 1

preserving Files extentions when dropping into related items

Posted: 11 Oct 2018
by Roo
Is there a way of keeping the file extension when using the related item file renaming function? In the instructions it shows you how to hard code to a .txt file.

Re: preserving Files extentions when dropping into related items

Posted: 11 Oct 2018
by AlexZver
Hi Roo,

Yep, you can extract the file extension by this code:

Code: Select all

listItem.get_fieldValues().File_x0020_Type

Re: preserving Files extentions when dropping into related items

Posted: 12 Oct 2018
by Roo
Thanks for that. Works perfectly. :D

Re: preserving Files extentions when dropping into related items

Posted: 21 Nov 2018
by Roo
For Some reason this Has stopped functioning?? i've deleted the form and rebuild. Im completely lost as it was working fine.

fd.updateDroppedDocuments($('.RTWForm'), function(listItem) {
//get the values from the Form fields:
var fidr = parseInt(window.top.GetUrlKeyValue('ID'));
var prefixr = Date.now()/ 1000 | 0;
var Employeer = fd.field("Employee_x0020_Name").control('data')['Employee_x0020_Name'];
var rdater = fd.field("RecordedDate").value();
var extnr = listItem.get_fieldValues().File_x0020_Type
var newNamer = prefixr + " " + fidr + " " + Employeer + "." + extnr;

//file name with the current directory:
var newFileNamer = listItem.get_item('FileDirRef') + '/' + newNamer;
//set the values on uploaded document:
listItem.set_item('Title', fidr);
listItem.set_item('Employee_x0020_Name', Employeer);
listItem.set_item('RecordedDate', rdater);

listItem.update();
listItem.update();
listItem.get_file().moveTo(newFileNamer);

});

Re: preserving Files extentions when dropping into related items

Posted: 22 Nov 2018
by AlexZver
Dear Roo,

The same functionality works on my test tenant.

1) Have you noticed any errors in the browser console? If so, please send us a screenshot.

2) Have you tried to rebuild the form with the same related Documents library or with a brand new one? Could you please try to create a new Documents library and try to build a form with it?

Re: preserving Files extentions when dropping into related items

Posted: 23 Nov 2018
by Roo
Hi - It was a problem with this:

var rdater = fd.field("RecordedDate").value();
(Date field)
I have changed it to:
var rdater = fd.field("RecordedDate").control('getDate');

Re: preserving Files extentions when dropping into related items

Posted: 26 Nov 2018
by AlexZver
Hi Roo!

I'm glad you've found a cause of your issue!

Strange thing, the same code works for me. I'll do some research on this.