Skip to content

Instantly share code, notes, and snippets.

@mikeplate
Last active November 23, 2020 14:13
Show Gist options
  • Save mikeplate/32084cf4b010aa41c60ee5d07d7fb0cd to your computer and use it in GitHub Desktop.
Save mikeplate/32084cf4b010aa41c60ee5d07d7fb0cd to your computer and use it in GitHub Desktop.
SharePoint Column Formatting Download Link
{
"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', '')"
}
}
]
}
{
"elmType": "span",
"txtContent": "=getYear(@currentField)+if(getMonth(@currentField)<9, '-0','-')+(getMonth(@currentField)+1)+if(getDate(@currentField)<10, '-0', '-')+getDate(@currentField)+' '+toLocaleTimeString(@currentField)"
}
@mikeplate
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment