Skip to content

I have a question about SAMPLE generic-hyperlink-values #584

Open
@oshihirii

Description

@oshihirii

Sample

https://github.com/pnp/List-Formatting/tree/master/column-samples/generic-hyperlink-values

Question

The code shown in the example above:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "target": "_blank",
    "href": "='http://finance.yahoo.com/quote/' + @currentField"
  }
}

works well as long as the dynamic URL:

  • isn't a link to a SharePoint resource
  • which includes characters such as an ampersand &

For example, I am trying to generate a dynamic URL based on the value in another column.

The dynamic URL is a link to a filtered view of a document library, eg:

"attributes": {
  "target": "_blank",
  "href": "='https://tenant-name.sharepoint.com/sites/site-name/cd/Forms/My%20View%20Name.aspx?env=WebViewList&FilterField1=My_x0020_Reference&FilterValue1=' + [$Title]"
}

If the value in the other column includes an ampersand &, the URL breaks when clicking on the dynamic URL.

Is there anyway to URL encode the column value when adding it to the dynamic URL?

Metadata

Metadata

Assignees

Labels

❓ QuestionQuestion about one of the samples

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions