I have added some Javascript to an opportunity form to test for appid in the URL, and, if not present, reopen the page with the appid included.
This is my code:
function checkAndRedirectToAppId(executionContext) { var globalContext = Xrm.Utility.getGlobalContext(); var oId = executionContext.getFormContext().data.entity.getId().replace(/{|}/g, ''); var uRL = globalContext.getCurrentAppUrl(); if (uRL.toUpperCase().includes("APPID") == false) { var newURL = uRL.concat("/main.aspx","?appid=d12fc2ac-c9ad-4391-adb4-8c471838b68d","&pagetype=entityrecord","&etn=opportunity","&id=",oId); Xrm.Navigation.openUrl(newURL); } }
Unfortunately Xrm.Navigation.OpenUrl seems to do nothing.
I cannot use Xrm.Naviation.OpenForm (which was my other avenue of exploration) as it doesn't seem to support the appid as a parameter.