I have a problem where there are URLs hardcoded in a JavaScript web resource. The problem with this is that when taking a cut from production to other environments, these carry the production URLs with them. The other issue is that when performing releases from Dev’s upwards, the release team need to manually go into the JavaScript and update the URLs.
Am looking for a solution in which this is not hardcoded and requires the JavaScript to update each time we release. I’m looking for a generic approach to do this to avoid hard coding URLs.
Example of the hardcoded webresource
function exampleSearch() {
var devUrl = "https://namedev.crm4.dynamics.com/";
var uatUrl = "https://nameuat.crm4.dynamics.com/";
var prodUrl = "https://name.crm4.dynamics.com/";
var bauUrl = "https://namebau.crm4.dynamics.com/";
var serverUrl = Xrm.Page.context.getServerUrl();
if (serverUrl == devUrl) {
url = "https://devui.namecloud.com/examplesearch";
}
else if (serverUrl == uatUrl) {
url = "https://nameuatui.namecloud.com/examplesearch";
}
else if (serverUrl == prodUrl) {
url = "https://namecrm.namecloud.com/examplesearch";
}
else if (serverUrl == bauUrl) {
url = "https://nameuui.namecloud.com/examplesearch";
}
launch(url);
}
function launch(url) {
var w = 785, h = 650;
var left = (screen.width) ? (screen.width - w) / 2 : 0;
var top = (screen.height) ? (screen.height - h) / 2 : 0;
window.open(url, "w1", "resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width=" + w + ",height=" + h + ",left=" + left + ",top=" + top);
}
Am using dynamics online