10

I have added a button into my SharePoint list using SharePoint designer.

I want to be able to open a document from the button. So I go the url for the word document by going properties on the normal link in a SharePoint list for a document.

I then put the link in a hidden column. I am now trying to use window.location.href = {column name} and I am keep getting below error.

500 error.

I want to use a button to open a document because I want to trigger a workflow off when the user clicks on OPEN DOCUMENT button.

Does anyone have any ideas whats the best way ?

  • When you hover on the button, what URL you see at the bottom of the browser? And check whether its correct? – Asad Refai Dec 29 '15 at 9:59
  • 2
    A calculated column with HTML would work for this case. – Akhoy Dec 29 '15 at 10:02
3

If you have the URL in a column in the list, then you'll have to either:

  • Display it in the form and retrieve its value from the DOM to use in your script, or
  • Use SOAP/REST to retrieve the column value from the list

What you're trying to do above would be a little magical. ;-)

1

Hover on the button you can see left bottom side which URL you are going to re-directing so check with the URL, else Go to that column which include URL test it manually whether URL is correct.

  • when I hover over the button, there is not an url on the bottom left hand side . – Jason Hough Dec 29 '15 at 10:57
1

You can use a calculated column. The output type should be set to Number. Something like:

=CONCATENATE("<div><a href='http://mysite/list/ListName/DisplayForm.aspx?ID=",[ID],"'>Click Here</a></div>")

Another option would be to setup a multi-line text field, with rich text. Then run a workflow each time a new item is added to populate that text field with the HTML you need.

1

I would use a data view for this. Use your button in said data view and onclick of each item run some JavaScript. Your script would trigger the workflow then open your document.

I like the data view here because it is easy to embed something like an ID or any other property into your button, div, etc. I know you can get the same effect using a calculated column, but in my experience that can be clunky and doesn't always work how I'd like.

1

Why don't you try with JSLink. Refer: https://code.msdn.microsoft.com/office/Client-side-rendering-JS-2ed3538a

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.