Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Xrm.Navigation.OpenUrl does nothing

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.

  • Safety Nerves Profile Picture
    Safety Nerves 30 on at
    RE: Xrm.Navigation.OpenUrl does nothing

    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.

  • meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: Xrm.Navigation.OpenUrl does nothing

    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
    Safety Nerves 30 on at
    RE: Xrm.Navigation.OpenUrl does nothing

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

  • meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: Xrm.Navigation.OpenUrl does nothing

    Is this a new application you have created ?

  • Safety Nerves Profile Picture
    Safety Nerves 30 on at
    RE: Xrm.Navigation.OpenUrl does nothing

    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
    meelamri 13,204 User Group Leader on at
    RE: Xrm.Navigation.OpenUrl does nothing

    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. 

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans