Last active
November 23, 2020 14:13
-
-
Save mikeplate/32084cf4b010aa41c60ee5d07d7fb0cd to your computer and use it in GitHub Desktop.
SharePoint Column Formatting Download Link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"elmType": "div", | |
"style": { | |
"padding": "0 10px", | |
"background-color": "=if((@currentField - @now) > 864000000, '', '')" | |
}, | |
"children": [ | |
{ | |
"elmType": "span", | |
"txtContent": "=@currentField" | |
}, | |
{ | |
"elmType": "img", | |
"style": { | |
"display": "inline-block", | |
"margin-left": "5px" | |
}, | |
"attributes": { | |
"src": "=if((@currentField - @now) < 86400000, @currentWeb+'/SiteAssets/INVID/Images/expired.png', if((@currentField - @now) < 2592000000, @currentWeb+'/SiteAssets/INVID/Images/warning.png', '')" | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"elmType": "span", | |
"txtContent": "=getYear(@currentField)+if(getMonth(@currentField)<9, '-0','-')+(getMonth(@currentField)+1)+if(getDate(@currentField)<10, '-0', '-')+getDate(@currentField)+' '+toLocaleTimeString(@currentField)" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", | |
"elmType": "a", | |
"txtContent": "=if([$FSObjType]=='0', [$FileLeafRef], @currentField)", | |
"attributes": { | |
"href": "=@currentWeb + [$FileRef]" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually, the txtContent property if statement does not change anything. In this case [$FileLeafRef] and @currentField are the same. I was hoping for the folder links to be able to load dynamically without reloading the whole page but it does not work. I would have liked to have an if statement for the whole formatting rule so that it was only applied for files and not folders, but I haven't found way to do that.