Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda