2

Basically I need to find out the item URL to populate the href attribute of an "a" element in a JSON view format (aka rowFormatter) in SharePoint online. Is there is predefined shortcut for the item URL?

     "elmType": "a",
     "attributes": {
       "href": "[$ItemUrl]"
     },
     "txtContent": "CLICK HERE"

I made the [$ItemUrl] up, it does not work like this.

3

You could use $ID.

Sample demo:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "target": "_blank",
    "href": "= @currentWeb + '/ChildB/DispForm.aspx?ID=' + [$ID]"
  }
}
| improve this answer | |
  • It works but it doesn't new window with selected item, not the right pannel (with or without custom form). – VNO Jul 19 '19 at 12:58
1

There is another option that is to just use the defaultClick aciton:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "defaultClick"
  },
  "attributes": {
    "class": "ms-fontColor-black ms-fontColor-themePrimary--hover",
    "title": "Open eFolder"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer",
    "padding-left": "0px"
  },
  "children": [
    {
      "elmType": "span",
      "txtContent": "[$Name]"
    }
  ]
}

This way you dont need to worry about url string buildup

| improve this answer | |
0
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "target": "_blank",
    "href": "='/sites/Developer/Lists/ChildB/EditForm.aspx?ID=' + [$ID]"
  }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.