Category by getAssociationIDs NULL results

Forum for users and developers of Bullhorn's Webservices API suite

Moderators: StaffingSupport, s.emmons, BullhornSupport

Post Reply
enapoleone
User
Posts: 28
Joined: Sat Nov 17, 2012 12:06 am

Category by getAssociationIDs NULL results

Post by enapoleone » Fri May 10, 2013 10:51 am

When attempting to retrieve Category data for JobOrders by getAssociatesIDs many results are NULL. Below is an example of how I'm trying to do this:

Code: Select all

// Find the Category IDs for each Job Order ID using the getAssociatoionIDs method
    
$category_ids = array();

foreach($job_order_ids as $id) {
    $find_request = array(
            'session'         => $client->session,
            'entityName'      => 'JobOrder',
            'id'              => new SoapVar($id,XSD_INTEGER,'int','http://www.w3.org/2001/XMLSchema'),
            'associationName' => 'categories'
    );

    try{
        $findResult = $client->getAssociationIDs($find_request);
        $category_ids[$id] = $findResult->return->ids;
    } catch (SoapFault $fault) {
        watchdog('bullhorn job board',"Failed to find Bullhorn Category IDs for Job Order ($id) by AssociationIDs.<br />\nSoapClient::getLastRequest: %get_last_request<br />\nSoapFault: %soap_fault",array('%get_last_request' => $client->__getLastRequest(), '%soap_fault' => $fault->faultstring),WATCHDOG_CRITICAL);
    }
    
    $client->session = $findResult->return->session;
}

// Split the IDs into chunks and run through findMultiple
$category_chunks = array_chunk($category_ids, 20,TRUE);

//Find the Category occupation name for each Category ID and push it onto the categories Array

$categories = array();
foreach($category_chunks as $chunk) {
    $entity = 'Category';
    $categoryResult = bullhorn_find_multiple($chunk, $entity);
    $categories = array_merge($categories, (array) $categoryResult->return->dtos);        
}
    
function bullhorn_find_multiple($chunk,$entity) {
    global $client;
    
    $result = 0;
    
    $findId_array = array();
    
    foreach($chunk as $id) {
        $findId_array[] = new SoapVar($id, XSD_INTEGER,"int","http://www.w3.org/2001/XMLSchema");
    }

    $find_request = array(
        'session'    => $client->session,
        'entityName' => $entity,
        'ids'        => $findId_array,
    );

    try {
        $result = $client->findMultiple($find_request);
//            debug($findResult);
    } catch (SoapFault $fault) {
//        debug($client->__getLastRequest());
//        debug($fault->faultstring);
        watchdog('bullhorn',"Bullhorn Find Multiple Failed<br />\nSoapClient::getLastRequest: %get_last_request<br />\nSoapFault: %soap_fault",array('%get_last_request' => $client->__getLastRequest(), '%soap_fault' => $fault->faultstring),WATCHDOG_CRITICAL);
    }
    
    return $result;
}
When I view the Requirements for the JobOrders with NULL Category data through the Bullhorn Admin I can see that there is a Category assigned to each of them. Thus I don't understand why my query returns NULL.

Alliance
User
Posts: 40
Joined: Mon Feb 18, 2013 12:16 pm

Re: Category by getAssociationIDs NULL results

Post by Alliance » Fri May 10, 2013 3:59 pm

Don't see the problem straight away but when in doubt, print it out.

1. var_dump($job_order_ids) at the top. Confirm that the array is filled with valid jobOrderID's.
2. var_dump($category_ids) before your array_chunk. Confirm that the category array is filled with valid Category IDs.
3. If you didn't see a problem from steps 1 and 2 and both those arrays are filled correctly with valid data, start sticking debug prints inside your bullhorn_find_multiple() function to see what you are passing and compare it to what you are getting in return.

Also, you say "many results are NULL". But not all results. Figure out which results are not NULL and what differentiates those JobOrders and Categories from the rest.

enapoleone
User
Posts: 28
Joined: Sat Nov 17, 2012 12:06 am

Re: Category by getAssociationIDs NULL results

Post by enapoleone » Fri May 10, 2013 5:57 pm

Hi Alliance,

I've been doing all of that except for each call to bullhorn_find_multiple(). My var_dumps are returning IDs i.e. nothing is empty, however how do I determine if the IDs are 'valid'?

enapoleone
User
Posts: 28
Joined: Sat Nov 17, 2012 12:06 am

Re: Category by getAssociationIDs NULL results

Post by enapoleone » Sun May 12, 2013 11:03 pm

Here's an example of an XML request and response where the return dto is empty, NULL. My client's Job Orders are full of CategoryIDs like these, they are not always the same CategoryID but the following is just an example.

Request:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://apiservice.bullhorn.com/"><SOAP-ENV:Body><ns1:find><session>rO0ABXVyAAJbQqzzF/gGCFTgAgAAeHAAAAJQOmuSyZwAwEzLsw0fbqwhsLa488ExD0jJjLmexKL/
w9kYyl44TOp7U/5J+rGchVEZ4IVeaG97pXM+rJOgSE4Ow1olH+z9jQi1jBkyIwy2KslO/XUQydQh
88HdYpD/+j4A9sgde/RIR2+n90XCJkTh3EYXVrvr/LwM4QnB7u8eYx5fCId3oYW3RnL4jCfT0Ow2
368XOY/cM6PujI5hSc9TgdnTpKFJLqXRflTQJfB+dp08yayzkXp28pxhHD44Tp0PbW/DY5oaEy4t
uaR8ITbUKveYqwhOMYI36Z42tVRc4UzkYMLQ2pmNIHK3NBPqR0a4FCOWrYfUMj5ylnKAoSay5pkh
4ZgEwijdOkXyRgGC51yT0z/dBszmpPUmcx/Vw2JbanDLnr7xdT3RBT+LGAmUbZv41wom1IrmnfaJ
I7OVGth5GWaNNs7FVAyBJjSEJH1HoS0ZBqen2cAzUXhrgCBj4Nh5hOVfOXd2ct8VmJUcGC4u4M7s
jd7o39V878NYRFNSCeJqgBAVKBZ/KBh/uH+ajcyh3bnQ1AHJ92PCunWMXja1Rd84QH17PIIaUAGF
iBNNHCPRcDE9Pjo8IYjI0L4sTd9jZkSjd262e4cf0NCnt0gJCj1f/dauPvxdsluREK/cb7e2JISd
nNrl/9279DWCDZ29M1XrGxtD1NRkMUn9DjD/SDofmEpDa1FfZiN9ss6/KEqJxLDO08NI6cfb9bN1
1JlogSXD2mdo4nPMY8BF5BwpVSg0J2LifRBZm4zmsFAJXM8Onl2dQyUypUolgx24cQ==</session><entityName>Category</entityName><id xsi:type="xsd:int">692516</id></ns1:find></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response:

Code: Select all

<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:findResponse xmlns:ns2="http://apiservice.bullhorn.com/"><return><session>rO0ABXVyAAJbQqzzF/gGCFTgAgAAeHAAAAJQjKg4YtijWjE6WEsbuF3EhJq+uKy8TxPzjfUnFKoQ
bqkx9GO6MVDP/ghz4WVEd0q0f8lxKvN3aKBkbKg1X9M8l8hWxrfcuK/Pxypitany6XNc+oF31mqx
upLKUmbUER0N4YHvgYLUsd2dE+Wjl/azpntIx/Eqi9k+Gz3cWUBhW0i6FMBD/Jd1O3wWKRns6YsB
Pr89KlbqngcoWXjchzCsWO8DuGI6IxlVzf02R7NJUXeAifTVUgG024A1T5mry0tszi58+LUTJmr1
yYSGWEDg0EdSdQWFr+AmnVi/3FLDqrbAp0l8gH0FDeH5U64TSjHZPWHhO6v/mwG81aH0VdE24fbU
czooUvpsr9iLnC+onH2NMHgq1TlbfNrJpEMJRHhN6r+ohznXTakJLsET7/g9VP0d2sAT9c6ioSSX
AVWqg/iF6+AwOxaIY42Itaeq2Addq3JWvqpC2LPB1HJyXBbLcJ7QRms2bKPd/D4yIlIjP9RlyO3/
rmV5tMLjKjliO1pAJUm2m0hWWih25WPZzWeVy9R8y7SYV4bPKEQ1WVumxxzEyAKdKYkqPKoVlVAN
MumfULD5uR423+qht+WSiFXhMI6e0uZFcLsZ92KTBkWBHMjChFslbATM2AuVpZ+vjQfm58QV2PcI
JTz5NMUUZHOVPGNc6ci3NJ7VDNQx6mSTYLY2nfMJkMtD2Th9rty7Ba/dFmGnGtgSFnh/WCWyY8Ox
IG3n+gEoCZ1NLvnR7gtfvDPBXXQqYR6INflWqEU0nMgFnu728MvV7hyVVmRp/niDWQ==</session></return></ns2:findResponse></S:Body></S:Envelope>
Is it possible that the Category my client is assigning to these Requirements are invalid?

Alliance
User
Posts: 40
Joined: Mon Feb 18, 2013 12:16 pm

Re: Category by getAssociationIDs NULL results

Post by Alliance » Wed May 15, 2013 9:31 am

If you are getting IDs back, they are probably valid. Just log into Bullhorn and use the Fast Find feature to search for an ID or two and verify that it is indeed a valid Candidate.

The next place to look would be inside your bullhorn_find_multiple() call. I would var_dump() your $find_request array before you call findMultiple() and ensure that each element, including $findId_array, is properly constructed before you're attempting the findMultiple() call.

I'd also dump $chunk on the inside of bullhorn_find_multiple() to make sure you're getting what you think you're getting.

Post Reply