SyntaxEditor Code Snippet
i am storing file name in the table. need to retrieve the filename extension on the table record to display the extension alone in one of the table Column. how do i do it.
String_Split(MDDocumentTable.List.Current.MD_Documents.FileName,".")
IF( String_Split(MDDocumentTable.List.Current.MD_Documents.FileName,".").length>1,
String_Split(MDDocumentTable.List.Current.MD_Documents.FileName,".")[1].Text.Value,"")
RMS wrote:
Hi RMS,
you can get the extension of the image from the output of the string split by using the below code
String_Split.List[1].Text.Value
use this:
just drag and put yours accordingly:
Thanks for the prompt response, Worked Well.
Hi
Here I have attached a file which contains a javascript on uploadonchange action that filters the extension of the file.
Hope this will helps.
Thanks
To those who might see the selected answer, it doesn't work for filenames with multiple dots. Example: filenames.can.have.dots.xlsx
A better solution is the following:
If( String_Split(Filename,".").Length>1,String_Split(Filename,".")[String_Split(Filename,".").Length -1].Text.Value,"")
I suggest you run the String_Split in its node to avoid running it 3 times.
Another approach is to use the substr() method. Multiple dots within the filename do not matter, because the FileExtension is searched from behind.
FileExtension = Substr(Filename,Length(Filename) - (Length(Filename) - Index(Filename,".",searchFromEnd:True) - 1),Length(Filename))
Filename = Substr(Filename,0,Index(Filename,".",searchFromEnd:True))
The file extension is searched by taking the filename and searching the index of the first point in the filename from behind. Start of the substring is the total length of the filename - the index of the first point from the end (in addition -1 is used to not include the dot in the extension).