Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

json - Sharepoint library column button with condition

got customized "button" column in SharePoint library.

And I want the button to be visible only where value in another column called "Name" contain string "Permission".

My JSON:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"customRowAction": {
  "action": "executeFlow",
  "actionParams": "{"id": "6b294902-f477-4657-819e-74bcfd2c92af"}"
},
"attributes": {
  "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
},
"style": {
  "border": "2px solid black",
  "background-color": "transparent",
  "cursor": "pointer",
  "visibility": {
        "operator": "?",
        "operands": [
          {
            "operator": "==",
            "operands": [
              "[$Name]",
              "CONDITION"
            ]
          },
          "visible",
          "hidden"
        ]
      }
},
"children": [
  {
    "elmType": "span",
    "txtContent": "Update permissions"
  }
]
}

   
question from:https://stackoverflow.com/questions/65920999/sharepoint-library-column-button-with-condition

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try to use indexOf to check if the field conatins "Permission" string, please see the modified Json below:

 {
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"customRowAction": {
  "action": "executeFlow",
  "actionParams": "{"id": "6b294902-f477-4657-819e-74bcfd2c92af"}"
},
"attributes": {
  "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
},
"style": {
  "border": "2px solid black",
  "background-color": "transparent",
  "cursor": "pointer",
  "visibility": "=if(indexOf(toLowerCase([$FileLeafRef]),'permission') != -1, 'visible','hidden')"
},
"children": [
  {
    "elmType": "span",
    "txtContent": "Update permissions"
  }
]
}

enter image description here

Reference:

Formatting Values Using “Contains” in List Formatting


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...