JohnD
JohnD

Reputation: 345

Is there any way to pass configuration parameters to an Outlook Addin

I have a JS Outlook Add-in that I'd like to be able to deploy to multiple sites, but I'd like to deploy the same code to every site and handle configuration data externally, if possible. Something like process.env (that works for a Node.js server App) for a client App. I see it's possible to define Application Settings in Azure, but how can I access the values in the App?

Upvotes: 3

Views: 1181

Answers (3)

Trichter
Trichter

Reputation: 603

I want to extend @JohnD's answer for everyone who wants to have an example:

1. Attach query param to your Taskpane url:

<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html?param=myParameter"/>

2. Get the parameter in JavaScript

let queryString = window.location.search;
// ?param=myParameter
let param = new URLSearchParams(queryString);
// param=myParameter
let myParam = param.get("param");
// myParameter

This is an example on how to use it. Hope it helps.

Upvotes: 1

JohnD
JohnD

Reputation: 345

Thanks Outlook Add-ins Team, that works fine; for the benefit for any other readers, a few details

  1. Extracting the parameter value in the target JS is made easy by using URLSearchParams()
  2. This solution concentrates the customer variance in the Manifest, leaving the bulk of the solution in JS that is the same for all deployments, a key objective
  3. As an aside: the customer variances to the Manifest can be reduced to minimum by using ~remoteAppUrl

Upvotes: 2

user7823505
user7823505

Reputation:

If you're able to distribute a different manifest to each customer, you can add a query parameter to any SourceLocation URLs in the manifest to pass information to the add-in on startup.

<bt:Url id="Taskpane.Url" DefaultValue="https://contoso.azurewebsites.net/Taskpane.html?<per-customer query string>" />

Upvotes: 4

Related Questions