Skip to main content

Notifications

Dynamics 365 general forum

While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

Posted on by 1,017

Hi, 

While trying to create a record in the custom entity we are getting the below error:

  • LeoAlt Profile Picture
    LeoAlt 16,329 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    Hi james,

    Have you resolved this issue?

    According to the error message, the "context" was not defined in "GetuserInfo" function.

    First you need to get the "context" object by code like this.

    var context=Xrm.Page.context. or var context=GetGlobalContext();

    Then you could use this "context.getServerUrl()" to do something.

    Note that the error is caused in your "GetUserInfo" function.

    Hope it helps.

    Best Regards,

    Leo

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    Hi James,

    You need to swap out the use of getServerUrl for getClientUrl in the GetUserInfo function. You can confirm that this is the cause of your issue by debugging your JavaScript.

  • yify Profile Picture
    yify 1,017 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    function GetUserInfo(fields) 

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    Hi James,

    On this line of JavaScript code you are calling the GetUserInfo function:

    var userInfo = GetUserInfo(fields);

    We need the code for this function.

  • yify Profile Picture
    yify 1,017 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    Code

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    Hi James,

    I can if you provide the code in your GetUserInfo function along with a screenshot of the error message and any associated log files.

  • yify Profile Picture
    yify 1,017 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    Hi,

    Can you please let me know what the modified code on this should look like

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    Hi James,

    Are you sure? Please examine the GetUserInfo function.

  • yify Profile Picture
    yify 1,017 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    Hi, In my code getServerUrl method is nowhere used

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: While clicking +button in a custom entity we are getting the TypeError: context.getServerUrl is not a function at GetUserInfo error

    Hi James,

    Use getClientUrl to return the base URL that was used to access the application, instead of the removed getServerUrl method.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans