Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Obtain URL query parameters

Posted on by 2

Is it possible in business central to programmatically obtain the query parameters for the current page?

Scenario:

  1. Hyperlink to a website that is external to business central
  2. User fills in form and submits on external website
  3. External website redirects back to business central and appends query parameters to the URL containing details related to the form submission

The external website interaction and redirect with query parameters are outside of my control.

Any thoughts are appreciated.

Categories:
  • xorlogic Profile Picture
    xorlogic 2 on at
    RE: Obtain URL query parameters

     yzhums 

    My understanding of and experience with GetUrl() is not that it gets the URL of the current page, but rather that it can be used to generate a URL for accessing a page/record/etc within the current server instance. As I understand it, the documentation that you linked to agrees with me.

    As for the https://yzhums.com/20111/ link, it wasn't immediately clear to me where it was obtaining the current URL. Regardless, the example solution seemed to be much more involved than the control addin approach I mentioned.

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    RE: Obtain URL query parameters

    Hi, if you just want to returns the URL of the current page, you can use System.GetUrl() Method:.

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-geturl-clienttype-string-objecttype-integer-table-boolean-method

    And just add another solution, this can also be done with Power Automate.

    https://yzhums.com/20111/

    Hope this helps as well.

    Thanks.

    ZHU

  • xorlogic Profile Picture
    xorlogic 2 on at
    RE: Obtain URL query parameters

    Continuing to explore this I actually came up with a better solution using a "control addin".

    Basically, the external web page will redirect back to a page in business central. This business central page will have a very simple control addin with custom JS that grabs the window.location and sends it to the control addin's callback.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Obtain URL query parameters

    My pleasure, happy to help!

    Please mark the question as answered if you found my help useful. That way you help both me and the community.

    You could also let the 3.party webside call an Azure logic app or Azure website that you control. And then you can do the call to Business Central from there. We have done that in some cases.

    Happy coding!

  • xorlogic Profile Picture
    xorlogic 2 on at
    RE: Obtain URL query parameters

    Fascinating! Thanks for all your feedback.

    The required auth credentials, expected as they are, still make this just out of reach for the external website which is merely performing a redirect off of the original page (3rd party, not in my control and won't change) and won't be including anything at that level in the request.

    However, a custom built intermediary with the ability to translate the redirect request into a meaningful REST request back to BC could be a way to work around the disconnect.

    Thanks again!

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Obtain URL query parameters

    You need to define your API, that also can be a to match the parameters in the http call.

    Here is a blog around using codeunits as API. I think that is the solution for you in this case.

    www.kauffmann.nl/.../

  • xorlogic Profile Picture
    xorlogic 2 on at
    RE: Obtain URL query parameters

    Interesting. The custom API may hold some promise.

    I could specify a custom GET endpoint and have the external website redirect back to that on form submission. Presumably there won't be any issues with the HTTP as long as no specific auth is required. I'm still not seeing anything about accessing query parameters and I'll have to modify the examples to somehow save in the request handler instead of merely returning data. Maybe I'll be able to stumble into something there.

    Thanks for the reference! I'll look into it some more.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Obtain URL query parameters

    So you want the external website to call a Business Central API?

    Then you can create a custom API in AL

    docs.microsoft.com/.../devenv-develop-custom-api

  • xorlogic Profile Picture
    xorlogic 2 on at
    RE: Obtain URL query parameters

    Thank you, Andy Sather. I followed your link to the yammer group, but I believe I will need an admin's approval before proceeding there.

    Thank you, NorthW. Unfortunately, this does not speak to my needs. The query parameters that I am referencing will be defined by an external website and do not relate to core Business Central in any way. What I need is a way to reference those query parameters from within my extension's AL code so that I can do something with the information that they represent.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans