My setup:
- SharePoint Online (part of Office 365)
- No access to server coded (.NET) solutions
- Document Library using the Document Set content type
- New Experience UI enabled
Use case:
I have a SP2013 Workflow that allows a user to make a change request for a document in the library. The workflow has Initiation Form Parameters and the data supplied for those parameters, along with a reference to the item that the workflow was run on are written to another list in the site. This all works just fine.
What I'm trying to do is create a column in the document library that allows a user to navigate to the workflow's Initiation Form directly instead of having to right-click on the item, choose "Advanced" and then "Workflows".
The link to the workflow's Initiation Form page (taken right out of the browser's address bar when manually navigating to it) in total looks like this (line breaks added for readability):
https://company.sharepoint.com/sites/ABC/wfsvc/e73969f753574a3bb30c8d3ce3ab9c56/WFInitForm.aspx
?List={f9b73015-1131-442d-95b8-9682149a27e6}
&ID=5
&ItemGuid={71AA92CE-2D37-4D43-B593-AB6004E9DCF0}
&TemplateID={64193686-AB59-4D44-B0EB-FBD8E2CB7A1F}
&WF4=1
&Source=https%3A%2F%2Fcompany%2Esharepoint%2Ecom%2Fsites%2FABC%2FCourseDocuments%2FForms%2FCourseDocuments%2Easpx%3FRootFolder%3D%252Fsites%252FDCU%252FCourseDocuments%252FBasic%2520Stuff%26FolderCTID%3D0x0120D52000E334520C326BA440BF6F86F3CA80AE2800E3DBD1BD3A1EA348A9D944A931464C4D
The ID
and ItemGuid
portions of the link will need to be dynamic as they will contain a reference to the specific library document that the workflow will need to run against. Everything else is static.
To dynamically produce this URL per each item, I've created a second workflow that is run when a new item in the library is added as well as being able to be run manually (for items already in the library) and that workflow does correctly produce the URL needed for each item.
The Problem:
This URL is longer than the 255 characters that the "Hyperlink or Picture" column accepts and so the workflow errors out when trying to write this URL to the column.
What I've Tried:
I've been at this a while now and found several posted work-arounds, none of which have worked:
- I've tried shortening the URL by making it relative (and so the full site URL can be removed) and placing that in the "Hyperlink or Picture" field but that resulted in a workflow error of "Invalid URL" even though the URL produced works when copied and pasted into the address bar.
- I've tried shortening the URL by encoding the static parts with Bitly and this time the workflow completed and wrote a clickable URL to the field, however while the static parts work individually, when they are concatenated with the other parts, the final URL leads to a 404 error at the Bitly site.
I've made a "Calculated" column that is set to "Date/Time" result and made the calculation be a concatenation of parts of the URL into an HTML hyperlink syntax (i.e.
="<a href='"&[column1]&[column2]&[column3]&"'>Click</a>"
). While this did succeed in getting the entire thing produced and set into the library, with all the dynamic parts correct, the field doesn't render as parsed HTML, instead the full HTML markup is rendered, so it's not a clickable link. (The image below shows a relative URL, but with this approach, I used an absolute URL. The picture is meant to just show the result of markup being produced and not parsed.)- I've tried adding the "Full HTML content with formatting and constraints for publishing" field to my library (with the SharePoint Server Publishing Infrastructure Site Feature enabled) and got the same HTML markup being displayed as with the calculated column attempt above.
- I've tried using a "Multi-line" text field and gotten the same markup display as above as well.
- According to this article, there is no length limit for encoded URLs, so I tried encoding the entire URL and placing that into a "Hyperlink or Picture" field, but the workflow errors out on that with an "Invalid URL" message.
So, the bottom line is that I can create the URL needed but cannot find a way to get it placed into a field for each item in a way that makes it clickable as an actual hyperlink.
UPDATE:
In response to @Lukáš Nešpor suggestion below, I have tried variations of that but followed your instructions and tried again. I don't get the option for Column Formatting in the list itself, but I do get that option when configuring the column in List Settings, so that's where I entered the JSON.
But, when I try it, the JSON formatting doesn't work.