Getting the Organization ID of the user

Hello,

I am storing the organization ID of each integrated account in our database, but I can't seem to find it in the rest api response of SugarCRM.

I am using this endpoint for getting the current user data.

/rest/v11/me

The ID of the current user is present with the key "id", but there is no id for the organization that the user is part of.

Thanks.

  • Hi R V,

    Unfortunately, /rest/v11/me endpoint returns only a set of fields from the current user object. It consumes "retrieveCurrentUser" method from CurrentUserApi class under clients/base/api/CurrentUserApi.php.

    We had also encountered same problem in past and had to override the method "getUserData" to add our custom fields into the response of "me" endpoint. You can do so by extending the existing CurrentUserApi class to CustomCurrentUserApi class in custom/clients/base/api folder. More info here - https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Integration/Web_Services/v10/Extend… 

    Override the "getUserData" method and add your custom field to the $user_data array before returning the response.

    Let us know if this helps.

    Regards.

  • If you want to fetch an unique identifier of the company, that means, an ID of the company which has some SugarCRM instances, then you need the endpoint /rest/v11/metadata

    You will see the attribute config.uniqueKey which is the unique for a SugarCRM key which identify a Company.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada