bullhornjs icon indicating copy to clipboard operation
bullhornjs copied to clipboard

How to Access PL and user roles

Open ss513546039 opened this issue 7 years ago • 11 comments

We need to know which function/entity to access the PL of the person who logged in and their roles and responsibilities.

Thanks, Suresh Somasundaram

ss513546039 avatar Apr 11 '17 16:04 ss513546039

Hey Suresh,

First you should look at the REST API docs: http://developer.bullhorn.com/sites/default/files/BullhornRESTAPI_0_2.pdf

Page 102, talks about the /settings call this will return CORP and PL settings. To get a list of all available settings like so: https://rest.bullhorn.com/rest-services/e999/settings

Then access the values like so: https://rest.bullhorn.com/rest-services/e999/settings/userId,userEntitlements

To do this with BullhornJS:

// Get Bullhorn's HttpService, which will pull your rest endpoint and bhresttoken from cache
var http = Bullhorn.http();
// Get the endpoint you want access too, it returns a Promise
http.get('/settings').then(function(response) {
    console.log('First Setting', response.data[0].name); // outputs: 'accountLockoutDuration'
});
// To get specific settings, you can request them in a comma separated list
http.get('/settings/userId,userEntitlements').then(function(response) {
    console.log('settings', response);
    // {
        "userId": 5119506,
        "userEntitlements": [
            "Add Client Submission via Mobile",
            "Add Education",
            "Add Housing Complex Unit",
            ...
        ]
}
});

bvkimball avatar Apr 11 '17 22:04 bvkimball

Hi bvkimball,

http.get('/settings').then(function(response) { chkdata = JSON.stringify(response);

console.log('First chkdata---', chkdata);

});

http.get('/settings/userId,userEntitlements').then(function(response) { console.log('settings', response); });

We have tried and got userId which is 3 but this is not logdin user id I think.

Here so many objects I am getting but where I will get login User Id, i do not know. Also I have tried

Kindly give some idea or solution to get that particular value User Id of current logdin user.

Is it possible to get current logdin user's role,PL etc from Users/User object or followings value

User Type, Private Label etc.

Thanks, Hari

harigkp avatar Apr 14 '17 16:04 harigkp

You can use the userId received by the settings call to get the CorporateUser.

ie. ../entity/CorporateUser/3?fields=*

or with BullhornJS

var entity = new CorporateUser().fields('id','privateLabel(id,name)','userType(id,name)');
entity.get(3).then(...)

bvkimball avatar Apr 17 '17 17:04 bvkimball

I have tried http.get('/entity/CorporateUser/3?fields=*').then(function(response) { console.log('settings............', response); }); And getting following output but here not any Private Lable value, please see attached pl

Also tried var entity = new CorporateUser().fields('id','privateLabel(id,name)','userType(id,name)'); entity.get(3).then(function(response) { str = JSON.stringify(response); console.log('output---------------------', str); });

Uncaught ReferenceError: CorporateUser is not defined

Please let me know feasible solution.

harigkp avatar Apr 18 '17 10:04 harigkp

hmm, i will look into that.

You should be able to get the PrivateLabel ID from setting. hopefully that can be a workaround for now.

../settings/privateLabelId

bvkimball avatar Apr 18 '17 12:04 bvkimball

Hi, First of all http.get('/settings/userId,privateLabelId').then(function(response) { I have tested and here userId not correct

Now I hard coded passed user id in following http.get('/entity/CorporateUser/920363?fields=*').then(function(response) { console.log('settings............', response); });

I am getting correct information but not getting private lable of this user

Still we are facing same issue, not resolved

harigkp avatar Apr 18 '17 15:04 harigkp

http.get('/settings/userId,userEntitlements').then(function(response) {

here also userId not correct

harigkp avatar Apr 18 '17 15:04 harigkp

image we are looking to get the marked filed values for the logged in user.

ss513546039 avatar Apr 18 '17 17:04 ss513546039

At this time i am not sure if you will be able to get the 'name' of the privateLabel through the REST API. You can probably reach out to support or PS to get the corresponding ID for those PrivateLabels

bvkimball avatar Apr 19 '17 14:04 bvkimball

First of all I am not getting correct user which is login now in bullhorn. I have used ""http.get('/settings/userId,userEntitlements').then(function(response) {" as you suggested. But not getting correct userId.

Second for privatelabelId for current user

http.get('/entity/CorporateUser/920363?fields=*').then(function(response) { chkdata = JSON.stringify(response); console.log('private Label ID............', chkdata); });

Here please see I pass fields=* for all fiels and want all fiels which are associated with that user but I m not getting privateLabelId which associated with current user. It means access level permission still there.

Also I read BullhornRESTAPI_0_1.pdf "Generally, user can read all entities. If the entity can be categorized into private and non-private, the user cannot read private entities owned by other users unless the user has the READ_PRIVATE entitlement."

Kindly see and help would appreciated.

harigkp avatar Apr 20 '17 16:04 harigkp

Getting issue in private label Id

I have made user for comforce health and credentials as follows:

image Now, I have created a candidate 920557 | hari test comforce this will make for comforce candidate.

Now, I have login through above credential and try to validate this candidate according to comforce, means I need to check “G2 ComforceHealth” for internal submission, client submission etc. based on private label id.

But issue is I am getting private label id 19801 which for ACS Group - AIC (Dev) through code. This is wrong. Code response from bullhorn is as follows. image Expected output will be ACS Group - ComforceHealth (Dev) and private lable id will be 19803.

So, I am unable to validate in case of private label id, in case of private Label Value working fine.

harigkp avatar May 12 '17 15:05 harigkp