User's companyName attribute

In SharePoint forms (O365), I'm using a User field to pull in the attributes of a user and auto-complete some fields in my form. However, the companyName is not one of the returned attributes (I found them using the console.log return from the UserProfileProperties).

How can I get the user's companyName field from MS Entra/Graph/O365?

Dear @Gabe_Giacomo,
What do you mean by:

I found them using the console.log return from the UserProfileProperties

If you managed to find it - can you post code and screenshot of what you've found, we can help access this data. If it's available in the console - it's available on the form.

If you didn't manage to find in console, please, specify what property exactly you're looking for, and where it's found for editing (admin center or somewhere else).

Hey Nikita -
Sorry, I meant that I didnot see it in the console.

In MS Entra (Azure AD), the field is companyName on the user's record under, the Job Information section. It does not appear to exist in the SharePoint Admin center user profiles however.

Azure AD/Entra:
image

Hello @Gabe_Giacomo ,
a several months ago I tried to figure this out too for guset users - we used a different user property. On SharePoint On-premises you can edit the user attributes, but I am not sure if you are able to do it for SharePoint Online, the settings is here:

  • https://{yourTenant}-admin.sharepoint.com/_layouts/15/TenantProfileAdmin/ManageUserProfileServiceApplication.aspx
    (You are able to add a new custom attribute, but it will not let you add anything).

Other way, I have listed my properties on my test tenant and have not found any mention about company.
Use this script to list the properties in the console:

window.pnp = pnp;
fd.spRendered(() => {
  function updateCurrentUserInfo() {
    pnp.sp.profiles.myProperties.get().then(function (result) {
      const props = result.UserProfileProperties;
      console.log(props);
    });
  }
  updateCurrentUserInfo();
});

You can also try this because Graph is included in the Plumsail Forms.

function fetchCompanyFromAzureAD() {
  graph
    .me()
    .then((props) => {
      console.log(props);
    })
    .catch((error) => {
      console.error(error);
    });
}
fetchCompanyFromAzureAD();

Here you can find anything about User Profile Application and in the FAQ is the question about custom properties.

EDIT: 6 hours ago, on my test tenant, I have added to my profile a company attribute, but still cannot see it in the developer console. I am worried about that this attribute will not be present in the developer console and will not be a part of user objects on SharePoint.

2 Likes

Hi StepanS - Yeah, that's the same code I was using to get the properties in the console. I'm 99% sure it's using the SharePoint admin center "User" fields, which does not include the Company (companyName or company) like AAD or O365 has.

I'll have to see if I can get it with graph instead.

Thanks for taking a crack at it!

1 Like