Sep 11 2023 10:29 AM - edited Sep 11 2023 10:33 AM
I have set up a templates repository for my company with a PowerShell command.
Now, I would like to constrain company users to save all outputs files created from a specific template into the same location on SharePoint. For example, if I have a 'Purchase Order' template, I want to force all users to save the documents created from the 'Purchase Order' template into the 'Purchase Order' folder on the company's SharePoint. Is there any way to do this?
Thanks a lot for your help, it's greatly appreciated!
Sep 11 2023 11:00 PM
Hi @aurorecarles ,
we solved that by applying a json format to that view.
First we created a new gallery view and the applied this formatting sheet:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
"height": 293,
"width": 254,
"hideSelection": true,
"fillHorizontally": true,
"formatter": {
"elmType": "div",
"attributes": {
"class": "sp-card-container"
},
"children": [
{
"elmType": "div"
},
{
"elmType": "div",
"attributes": {
"class": "ms-bgColor-white sp-css-borderColor-neutralLight sp-card-borderHighlight sp-card-subContainer"
},
"children": [
{
"elmType": "div",
"attributes": {
"class": "sp-card-previewColumnContainer"
},
"children": [
{
"elmType": "div",
"attributes": {
"class": "sp-card-imageContainer"
},
"children": [
{
"elmType": "filepreview",
"attributes": {
"src": "@thumbnail.512x432"
},
"style": {
"height": "200px"
},
"filePreviewProps": {
"fileTypeIconClass": "sp-fileTypeIcon-cardDesigner",
"brandTypeIconClass": "sp-brandTypeIcon-cardDesigner"
}
}
]
}
]
},
{
"elmType": "div",
"attributes": {
"class": "sp-card-lastTextColumnContainer"
},
"children": [
{
"elmType": "p",
"attributes": {
"class": "ms-fontColor-neutralSecondary sp-card-label"
},
"txtContent": "[!FileLeafRef.DisplayName]"
},
{
"elmType": "p",
"attributes": {
"class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent sp-card-keyboard-focusable"
},
"txtContent": "[$FileLeafRef]"
},
{
"elmType": "p",
"attributes": {
"class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent sp-card-keyboard-focusable"
},
"children": [
{
"elmType": "a",
"txtContent": "Download",
"attributes": {
"class": "sp-card-defaultClickButton",
"role": "presentation",
"target": "_blank",
"href": "=@currentWeb+'/_layouts/download.aspx?SourceUrl='+[$FileRef]"
},
"style": {
"padding": "10px",
"height": "32px",
"margin-right": "8px",
"margin-botton": "10px",
"font-size": "14px",
"border-radius": "2px",
"border": "none",
"font-weight": "600",
"background-color": "#0078d4",
"cursor": "pointer",
"color": "white",
"text-decoration": "none",
"text-align": "center",
"width": "65px"
}
}
]
}
]
}
]
}
]
}
}
Now the documents in the gallery look like this
You can see a preview of the document and if you press the "Download" button, that file is being downloaded instead of being opened.
Best Regards,
Sven