Unleashing Dynamics 365 Excellence: Your Source for Pro Tips and Snippets at D365Snippets.com

Our blog provides a curated collection of tips, tricks, and code snippets that streamline your workflow and enhance your proficiency.
Unleashing Dynamics 365 Excellence: Your Source for Pro Tips and Snippets at D365Snippets.com

How to Open External URL in D365 Using X++ Code

0

In this article i write a small tip "how to open external URL in D365 using x++ code?". If you want to navigate the user’s browser to a different URL programmatically (and not by providing a link they can click) this can be done very easily by using the new class Browser.With the new version Dynamics AX or D365 there are new APIs that are needed because of the technological changes.

how-to-open-external-url-in-d365-using-xpp-code

The Browser class only has one single method, navigate, which has three parameters (of which only the first is mandatory): 

     - URL (string)
     - Prompt (boolean)
     - Open in new tab (boolean) 

In Visual Studio Create One Runnable Class, In the main method write the below code .

class ExternalURL
{        
    
    /// The specified arguments.
    public static void main(Args _args)
    {
        Browser browser = new Browser();
        browser.navigate('http://d365snippets.com', true, false);
    }
}

simple example using a runnable class could look like this . If you run it, it’ll open a new tab with the starting page of this blog.For best practice you create a action menu set its object type to class and set object with runnable class name. Add this menu item to required menu extension. Save compile On clicking menu item from navigation.A popup windows open,if your browser pop window is blocked, Allow popup option.If this code helps you please share to others. 

Happy coding with D365 Snippets

Post a Comment

0Comments
Post a Comment (0)