Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
How to get current user's business unit in Dynamics 365

How can I get business unit details of the logged-in user with javascript? I tried Xrm.Utility.getGlobalContext().userSettings but I couldn't get any information for business unit

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you write Xrm.Utility.getGlobalContext().userSettings I assume you are working with client-side javascript inside a Model-driven app.

From the userSettings you can get the userId property, it returns the GUID of the current user.

After you have this value in order to get details from the business unit of the user you need to do a retrieve request, something like this:

// get the userId
var userId = Xrm.Utility.getGlobalContext().userSettings.userId;
// remove { and } from the userId
userId = userId.replace("{", "").replace("}", "");
// Xrm.WebApi call to retrieve details of the user (fullname)
// and the name of the businessunit (name from expand)
Xrm.WebApi.online.retrieveRecord("systemuser", 
userId,
"?$select=fullname&$expand=businessunitid($select=name)").then(
function success(result) {
    console.log(result);
    // Columns
    var systemuserid = result["systemuserid"]; // Guid
    var fullname = result["fullname"]; // Text
    
    // Many To One Relationships
    if (result.hasOwnProperty("businessunitid")) {
        var businessunitid_name = result["businessunitid"]["name"]; // Text
    }
},
function(error) {
    console.log(error.message);
}
);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!