0
votes

I'm trying, in SharePoint Online, to make a column formatting that gets the file name but without the extension.

I've written a code that uses $FileLeafRef to get that, but it also returns the extension (ex.: document.docx)

{

"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",

"elmType": "div",

"txtContent": "[$FileLeafRef]"

}

I'd like to know if there is a possibility, like in PHP, to return only what is before the "."

Thanks

1
PHP is a language. JSON is a file format. Apples and origins.Amadan
Yes I know. And that's why I ask if there is a way despite thisMiki
You may want to rephrase your question though. JSON can't return anything. It is not executable, it is text. It's like politely asking a hamburger to teach you how to make vinaigrette. Hamburger is as likely to give you a response as JSON is. I am not familiar with Sharepoint Online; if your code is in JavaScript, ask about JavaScript, if it's .NET, ask about .NET etc. You need a programming language to do this.Amadan
Ok thank you for your help. As I'm not an English speaker, it's not easy for me to use appropriate terms. SharePoint does not use Javascript, I have to make it only with JSON... Thanks anywayMiki

1 Answers

0
votes

There is no OOB function to get file name only.

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

Workaround:

Create a workflow to update (title/or custom filed) value when file uploaded.

enter image description here