Skip to content

Question: How to pass configuration parameters to custom function's JavaScript context #130

Closed
@alaincao

Description

@alaincao

Hello there, this is more a question than an issue ; I hope this is the right place to ask ...

How can I pass general server configuration values to the custom functions context?
e.g. I have no problem within the taskpane context because I have access to a DOM where I can generate things like

<script>
window.myparameters = { napoleonsWhiteHorseColor:"Probably black" };
</script>
<script src="myaddin.js"/>

but I have difficulties understanding how to do that for the CustomFunctions context since there is no HTML file nor DOM...
I mean, without access to window.location.href, I'm not even sure how to get the current server's URL (without hard-coding it which I am definitively not going to do) ; I could use that to make some request to/someoptionalvirtualpath/myparameters.json.

I thought about polling the AsyncStorage regularily and wait for the taskpane to post them there, but that really doesn't seem right ...

Subsidiary question: is there a way to use more than 1 JavaScript file for the CustomFunctions context? I haven't seen any way in the manifest.xml.
e.g. { file_1: "http://server/parameters_generated.js", file_2: "http://server/myaddin.js" }

Thank you!

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions