How to get file extension
- AlexStenAlexSten
- Posts: 31
- Joined: Fri Apr 07, 2017
hello,
I'm working with Forms Designer from few months and would need some help.
Is it possible in a document library, via Forms Designer, to get the file name with extension in the field "NAME"?
I can create a custom view in SharePoint displaying more NAME fields, with file extension, but I don't know how to get this info in Forms Designer.
My task is to have in FD the field "NAME" with link to the file and the file type. Or at least to have the "File Type" in another field in the form.
thank you
I'm working with Forms Designer from few months and would need some help.
Is it possible in a document library, via Forms Designer, to get the file name with extension in the field "NAME"?
I can create a custom view in SharePoint displaying more NAME fields, with file extension, but I don't know how to get this info in Forms Designer.
My task is to have in FD the field "NAME" with link to the file and the file type. Or at least to have the "File Type" in another field in the form.
thank you
ciao,
Ale Stendardo
Ale Stendardo
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
Not sure that I got you. Where do you want to display an extension - in a Related Items control or as a separate field in a form?
Not sure that I got you. Where do you want to display an extension - in a Related Items control or as a separate field in a form?
- AlexStenAlexSten
- Posts: 31
- Joined: Fri Apr 07, 2017
hi Dmtry,
I'd need to display the extension or the full filename + extension in a separate field in the form.
I will have to get the file extension, because based on the extension, I will enable or disable by code some features (ie. save the form data).
Hope this is more clear. Thank you
I'd need to display the extension or the full filename + extension in a separate field in the form.
I will have to get the file extension, because based on the extension, I will enable or disable by code some features (ie. save the form data).
Hope this is more clear. Thank you
ciao,
Ale Stendardo
Ale Stendardo
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi Alex,
You can get an extension from the FileLeafRef control via JavaScript:
You can get an extension from the FileLeafRef control via JavaScript:
Code: Select all
fd.field('FileLeafRef').control()._el().find('.ms-fileField-fileExt').text()
- AlexStenAlexSten
- Posts: 31
- Joined: Fri Apr 07, 2017
Thank you very much Dmitry. It works well!
Just for "contribute" to the forum in some way, below the solution I was working on. As you can see it works, but is much more complex than yours.
Thanks a lot
>>>>
$(function ()
{
// begin work to call across network
var requestUri = _spPageContextInfo.webAbsoluteUrl +
"/_api/web/lists/getByTitle('a_TEST_documeto_PDF')/items?$select=FileLeafRef,File_x0020_Type,File/Name,File/Title&$expand=File";
// execute AJAX request
$.ajax({
url: requestUri,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function (data) {
$.each(data.d.results, function(i,result) {
alert(result.FileLeafRef +" | "+ result.File.Name + " | "+result.File_x0020_Type + " | "+ result.File.Title);
});
},
error: function () {
alert("Failed to get details");
}
});
});
>>>>>>
Just for "contribute" to the forum in some way, below the solution I was working on. As you can see it works, but is much more complex than yours.
Thanks a lot
>>>>
$(function ()
{
// begin work to call across network
var requestUri = _spPageContextInfo.webAbsoluteUrl +
"/_api/web/lists/getByTitle('a_TEST_documeto_PDF')/items?$select=FileLeafRef,File_x0020_Type,File/Name,File/Title&$expand=File";
// execute AJAX request
$.ajax({
url: requestUri,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function (data) {
$.each(data.d.results, function(i,result) {
alert(result.FileLeafRef +" | "+ result.File.Name + " | "+result.File_x0020_Type + " | "+ result.File.Title);
});
},
error: function () {
alert("Failed to get details");
}
});
});
>>>>>>
ciao,
Ale Stendardo
Ale Stendardo
-
- Information
-
Who is online
Users browsing this forum: No registered users and 3 guests