bullhorn / bullhornjs

javascript library to use the Bullhorn's REST APIs
MIT License
39 stars 11 forks source link

Unable to get custom objects using bullhornjs #4

Closed dilipid closed 7 years ago

dilipid commented 7 years ago

We are able to retrieve information of the regular entity objects with following codes, but unable to get the custom objects related to them, it may have to do with the way the parameters are passed or there may be different way of using the library to get the custom object attributes.

  1. [‎4/‎7/‎2017 2:30 PM] Somasundaram, Suresh:
    var candidate = new CandidateSearch().fields('id','name','mobile','customDate1','customObject1s').query(candidateID);; candidate.get().then(function(response){ candidate.get(candidateID ).then( function(entity) { str = JSON.stringify(entity, undefined, 4); alert(str);
    console.log(str); }); });

  2. var person= new Candidate().fields('id','name','lastName','customObject1s'); //works the same as above person.get(candidateID).then(function(response){ console.log('Job Title is ',response); });

Prompt response will be appreciated.

Thanks, Dilip Patel ACS Group 678-852-9895

bvkimball commented 7 years ago

Hi Dilip,

Your first issue is that you can't reuse the CandidateSearch object as a Candidate object:

var candidate = new CandidateSearch()
     .fields('id','name','mobile','customDate1','customObject1s')
     .query(candidateID);
             ^^^^^^^^ candidateID is not a valid query string 
candidate.get().then(function(response){
    candidate.get(candidateID ).then( function(entity) {
        ^^^^^^^ THIS IS DECLARED AS A SEARCH OBJECT
        str = JSON.stringify(entity, undefined, 4);
        alert(str);
        console.log(str);
    });
});

If you already have your candidateID as a number then you can use approach 2:

var person = new Candidate().fields('id','name','lastName','customObject1s');
person.get(candidateID).then(function(response){
        console.log('JSON RESPONSE', response);
        console.log('CustomObjectData', person.customObject1s);
});

Your data should look like this:

{
    "total": 100,
    "start": 0,
    "count": 20,
    "data": [
        {
            "id": 87,
            "name": "John Randall",
            "customObject1s": {
                "total": 0,
                "data": []
            },
        }, ...

Notice that the customObject1s will have a data structure of total & data.

Also please verify you have customObject1s configured and enabled in the Corp or TestCorp you are using. If you don't it will not be exposed through the API.

If you are still having issues after this, Please provide network requests and console logs.

ss513546039 commented 7 years ago

Hi Thanks for the response, we are getting this response and able to proceed, but we want to know is how to get all fields in custom page, for ex, we need to get the G2 details in candidate edit page, through from script how to access those details, can you please provide some details or some examples, it will be great helpful for us.

Thanks

bvkimball commented 7 years ago

Sorry I am not familiar with G2 details but yes you will be able to query any bullhorn object this way. You could also access input fields on the Edit Page with jQuery.

ss513546039 commented 7 years ago

Thanks, but we tried many ways, its not giving all the field level details, could you please check with your team or any sample code will be help better for us.

Regards, Suresh Somasundaram

bvkimball commented 7 years ago

I am sorry i still don't understand what field level details you are referring too. Are you talking about Field Metadata?

Have you looked at the REST Docs: http://bullhorn.github.io/rest-api-docs/#get-meta-entity

To do this with BullhornJS, the example is provided in the demo:

var meta = new CandidateMeta().fields('id','name','mobile','address');
meta.get().then(function(response){
    // You can access data from the http `response` or from `meta` directly
    console.log(response);
});
ss513546039 commented 7 years ago

We are not asking about meta, how to access the data in below fields, these are G2 fields, we trying to access like customObject1s.customDate1 but not getting any data

Database Field Label object4.customDate1 Availability to Start object4.customDate2 Availability to Interview object4.customText1 Current Work Visa Status object4.customFloat1 Current Compensation object4.customFloat2 Minimum Acceptable Compensation object4.customText2 Credentials object4.customText3 Encoder experience 1 object4.customText4 Abstracting systems object4.customText5 Electronic Record Access object4.customText6 Computer Assisted Coding object4.customText7 Are you currently working onsite or remotely? object4.customText8 Are you interested in remote, onsite or travel? object4.customText9 If not now, have you worked remotely before? If so, who, when and for how long? object4.customText10 If not now, have you worked as a travel coder before? If so, for whom, when, & how long, for whom? object4.customText11 If you take a travel assignment, would you be comfortable with 10 days on/4 days off? object4.customText12 Describe your experience setting up the VPN. object4.customText13 What hours/days are you available? How many hours daily to you expect to work? object4.customText14 Is there anything that would prevent you from traveling for training? object4.customText18 If you have worked remotely, how do you access the hospital’s charts (VPN or charts scanned?) object4.customText16 When working remotely, how do you contact the customer when you have trouble with the system? object4.customText17 Do you have a secure home office set up? object4.customTextBlock1 Tell me about your home office equip., current version of OS, dual screens, printer, scanner? object4.customTextBlock2 What are you hoping to accomplish with a move? When do you want to make the change? object4.customTextBlock3 Does your current employer know you are looking? object4.customTextBlock4 What other companies are you talking to? How far are you in their process? object4.customTextBlock5 What factors will you base your decision on? object1.customText16 Where have you submitted your resume recently? object1.customText17 Where have you interviewed recently? object1.customText18 Hiring Managers Name? object1.customText19 Do you have Vacation Plans in next 2-3 months? object1.customText20 Desired Locations / Commute radius object1.customTextBlock5 Clearance

Thanks, Suresh Somasundaram

bvkimball commented 7 years ago

Hi Suresh,

I still am not sure i am following which data you are specifically trying to get access too, but i am guessing you are saying that you want to get more fields data for the nested custom object.

This is because by default the TO_ONE or TO_MANY associations only return id or the default fields unless you specify otherwise. This is specified in the REST documentation, in the ENTITY FIELDS section: http://developer.bullhorn.com/sites/default/files/BullhornRESTAPI_0_2.pdf

To access this with BullhornJS, you can do either of the following:

var person = new Candidate().fields('id','customObject1s(*)');
// OR
var person = new Candidate().fields('id','customObject1s(id,date1,text1)');

Hope this is the answer you were looking for.

ss513546039 commented 7 years ago

Good Morning, Thanks for the details, it helps, we are able to get the details what we need.

Regards, Suresh Somasundaram