web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Xrm.Navigation.OpenUrl does nothing

(0) ShareShare
ReportReport
Posted on by 30

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.

I have the same question (0)
  • meelamri Profile Picture
    13,216 User Group Leader on at

    Hello,

    Your if condition will never go to false statement. In fact, globalContext.getCurrentAppUrl() will always contains "APPID". Please refer to documentation:

    docs.microsoft.com/.../getcurrentappurl

    Mehdi EL Amri

    Please tick as verified if the answer is useful. 

  • Safety Nerves Profile Picture
    30 on at

    Actually it does. If the appid is missing in the URL it returns just xxxxxxx.crmx.dynamics.com

    without the appid.  My first test was to "alert" rather than Xrm.Navigation.openUrl to check the conditional test was working as expected.

  • meelamri Profile Picture
    13,216 User Group Leader on at

    Is this a new application you have created ?

  • Safety Nerves Profile Picture
    30 on at

    It's about 2m old, but yes I did create it from scratch.

  • meelamri Profile Picture
    13,216 User Group Leader on at

    Please check if you can find your application in Model-driven Apps in the default solution. globalContext.getCurrentAppUrl() works for Model-driven Apps only.

    Mehdi El Amri

    Please tick as verified if the answer is useful. 

  • Safety Nerves Profile Picture
    30 on at

    The app is in the default solution.

    The issue I have is not with the globalContext.getCurrentAppUrl() part of the script, but the Xrm.Navigation.openUrl part.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans