Created a dynamic URL within a calculated column ="a href='/.../Test Doc Library/"&Title&"'>LINK</a> which works fine, but I need it to open as a modal and cannot get it to work.

I've tried adding a button to the field in designer, I've tried adding

<input id="ViewButton" onclick="javascript:OpenPopUpPage(/.../Test Doc Library/"&#39;Title&#39;"');" type="button" value="View Artifacts"/>

but it does not seem to recognize the dynamic Title portion.



in June 2017, Microsoft disabled the use of JavaScript in a Calculated Column

That means given answers may not apply for newer SharePoint versions

For long explanation and work arounds see:
June 13th 2017 Microsoft blocked handling HTML markup in SharePoint calculated fields - how to get the same functionality back

**Original answer:**

You are running into quoting issues because you need a " (double-quote) to identify the SharePoint string delimiters, so can not use it inside the string.

"" (double-double-quote) is the SharePoint escape notation to create a one double-quote inside a SharePoint string,
with the single-quote you then have the two required quoting styles required inside the SharePoint string to code JavaScript events.

Your Complete Calculated Column Formula becomes:

="<input id=""ViewButton"" 
     onclick=""javascript:OpenPopUpPage('/.../Test Doc Library/" & [Title] & "');"" 
     value=""View Artifacts""/>"


  • I documented it all:

  • https://www.365csi.nl/vm365com/#/How

  • https://www.365csi.nl/vm365com/#/Create

  • You could swap the use of single and double-double quotes; I found this use the best readable

  • The Browser will add double-quotes on Tag attributes at word boundaries, so you can use:

      ="<input id=ViewButton 
         onclick=""javascript:OpenPopUpPage('/.../Test Doc Library/" & [Title] & "');"" 
         value=""View Artifacts""/>"

if you had done value=View Artifacts it would have become:

value="View" "Artifacts"

  • [Title] can be written as Title, because it has no spaces. I tend to use the [] notation for readability

  • Always use a text-editor to prepare/edit your formulas with lots of linebreaking/indentation. Then paste to SharePoint, where SharePoint will remove all unnecessary spacing.

  • Top SO-SharePoint answers that use HTML/JavaScript in Calculated Columns
    are marked with ICC : https://sharepoint.stackexchange.com/search?q=ICC


Would you consider generating something simpler including the url, and then modify the DOM with javascript? Never used calculated columns to generate html.


Kindly try using below code...Minor changes have been done...Like (") replaced with (') and #39; is removed....

="<input id='ViewButton' 
         onclick='javascript:OpenPopUpPage(/.../Test Doc Library/"&Title&");' 
         value='View Artifacts'/>

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.