0

I'm looking to format the Site pages view using JSON Formatting. Is there a way to get the Published date field and also the page URL?

I see there is no column formatting on Name field on a library, but looking if there is a tweak to fetch the page url.

0

You can get the URL of Site page using [$FileRef]. This will be relative URL of page like:

sites/SiteName/SitePages/PageName.aspx

I was not able to find how to get the Published date field. But you can get the Created and Modified date using [$Created] and [$Modified] respectively.

You can use below JSON code on any field. It will show the current column value and on-click will redirect you respective to Site Page.

{   
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "a",
    "txtContent": "@currentField",
    "attributes": {
        "href": "[$FileRef]"
    }
}

References:

Use column formatting to customize SharePoint.

  • 1
    thanks for the response. FileRef works. I also needed File Name, not title. I was unable to get it through any references. So, created a workflow to update File name and also published dates to different fields. Was able to use them in the View Formatter. – Lucky Jan 28 at 18:13

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.