preserving Files extentions when dropping into related items

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

11 Oct 2018

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.

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

11 Oct 2018

Hi Roo,

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

Code: Select all

listItem.get_fieldValues().File_x0020_Type

User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

12 Oct 2018

Thanks for that. Works perfectly. :D

User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

21 Nov 2018

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);

});

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

22 Nov 2018

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?

User avatar
Roo
Posts: 107
Joined: Tue Oct 24, 2017

23 Nov 2018

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');

User avatar
AlexZver
Posts: 232
Joined: Mon Aug 27, 2018

26 Nov 2018

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.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 17 guests