- Add a URL button to your dashboard
- Give the button the URL of “**DOCUMENT**” this is a placeholder so we can find it in the code later
- dCode the dashboard
- Place the word document in the root of the dashboard (ie in the same place as the app.html file) In my example I will use the document called test.docx
- Open up the javascript file called components_1.js found in the gen_GUIDfolder
- paste the following code at the very top of that file
function replaceAll(str,find,replace){return str.replace(new RegExp(find,'g'),replace);} var split=window.location.href.split('/');var pop=split.pop();var joined=split.join();var url=replaceAll(joined,',','/');
- Search through the rest of the file for the placeholder “**DOCUMENT**”
- replace the placeholder (including the ” ) with
url+"/test.docx"
Change the file name as appropriate
- In my example the code now looks like this:
rt.setProperty(_xg_c,"url",url+"/test.docx")
- Now when you click on the URL button it will open / download the word document