Search code examples
javascriptdynamics-crm

How to get value of systemuser entity?


Im not a JS developer but i have to work on it. I have a problem with getting the value from systemuser entity on save event. My intend is getting the territory value but the problem is it says "Bad Request" when i click on save. Im searching on the net but could not find the solution.


Solution

  • Xrm.Page.context.getUserId() returns the guid of the current user including curly braces (e.g. {B05EC7CE-5D51-DF11-97E0-00155DB232D0}).

    When calling the Web API, you should send the guid without curly braces (e.g. /api/data/v8.1/systemusers(B05EC7CE-5D51-DF11-97E0-00155DB232D0)).

    You should thus strip the curly braces:

    "/api/data/v8.1/systemusers(" + userid.slice(1, -1) + ")"