How Can I Tell When an Update Fails?

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

Moderators: StaffingSupport, s.emmons, BullhornSupport

Post Reply
MancusoR
User
Posts: 1
Joined: Tue Jul 03, 2012 4:29 pm

How Can I Tell When an Update Fails?

Post by MancusoR » Tue Jul 03, 2012 4:37 pm

I have just gone through the sample for working with notes but it doesn't mention what kind of error I may get if the update fails?

Specifically, I'm concerned with the part of the code where the the Note is saved. How will I know if it fails? What kind of messages will I receive?

Better yet, how will I know that it has succeeded?

Here's the code snippet in C#
// 1.Save the note

apiSaveResult results = service.save(currentSession, noteDto); 2.The API returns a new session object. Refresh the session after calling the save operation.

// last step
currentSession = results.session;

juliet
User
Posts: 6
Joined: Tue Jul 10, 2012 11:43 am

Re: How Can I Tell When an Update Fails?

Post by juliet » Tue Jul 10, 2012 4:06 pm

Hi MancusoR,

This is Julie from Bullhorn Support, I will be assisting you with this question.

I suggest that you follow these listed best practices when saving Notes in order to avoid potential errors. First, obtain a valid Note DTO by doing a find on an existing Note ID - this DTO will serve as a template for your Save. Once you have the DTO, make sure to adjust accordingly depending on what you need to accomplish. If you want to update an existing Note, then simply enter in the updates in the appropriate fields. If you want to create a new Note, make sure to leave the ID field blank as a new ID will be automatically generated once you do the Save (and to avoid over-writing existing Notes). If your Save is successfully, the updated DTO or a blank DTO will be returned.

Since there are so many potential error messages you could receive, I don't really have a generic error message that I can offer you. The error messages tend to be very specific to what you are doing. I would just pay attention to the stack trace in order to identify where the point of failure is so you can go back in your code and make the appropriate corrections.

I hope this helps!

Best Regards,
Julie Thomas
Enterprise Support Analyst
B U L L H O R N
Staffing and Recruiting Software, On Target, On Demand
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
617-478-9126 (main)

shetc
User
Posts: 17
Joined: Fri Jul 20, 2012 2:46 pm

Re: How Can I Tell When an Update Fails?

Post by shetc » Fri Jul 20, 2012 2:50 pm

Hi Julie,

Two questions, please:

1) Is it possible to see the list of potential error messages?
2) What does the save function return that indicates that the update succeeded?

Thanks,
Steve Hiller
Randstad USA

juliet
User
Posts: 6
Joined: Tue Jul 10, 2012 11:43 am

Re: How Can I Tell When an Update Fails?

Post by juliet » Tue Jul 24, 2012 9:49 am

Hi Steve,

Unfortunately we do not have a distributable list of error messages. From my understanding, the amount of error messages you could potentially receive is quite large and very specific to what operation you are trying to perform.

A successful Save to update an existing DTO will return the updated DTO with all of its fields (including the non-updated fields).

Please let me know if you have any additional questions.

Best Regards,
Julie Thomas
Enterprise Support Analyst
B U L L H O R N
Staffing and Recruiting Software, On Target, On Demand
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
617-478-9126 (main)

shetc
User
Posts: 17
Joined: Fri Jul 20, 2012 2:46 pm

Re: How Can I Tell When an Update Fails?

Post by shetc » Tue Jul 24, 2012 9:58 am

Hi Julie,

Thanks for your reply. Here is a snippet of code:

Code: Select all

CandidateDto candidate = (CandidateDto)findResult.getDto();
//make some changes to candidate here
ApiSaveResult saveResult = service.save(bhSession, candidate);
bhSession = saveResult.getSession();
Please tell me what I do next to determine if the save worked or not.

Thanks,
Steve

shetc
User
Posts: 17
Joined: Fri Jul 20, 2012 2:46 pm

Re: How Can I Tell When an Update Fails?

Post by shetc » Tue Jul 24, 2012 10:26 am

Ok, I get it:

Code: Select all

CandidateDto candidate = (CandidateDto)findResult.getDto();
//make some changes to candidate here
ApiSaveResult saveResult = service.save(bhSession, candidate);
bhSession = saveResult.getSession();

candidate = (CandidateDto)saveResult.getDto();
if (candidate == null) {
  // throw an exception
}
So last question :D If there are validationErrors then no DTO is returned, and vice versa?

juliet
User
Posts: 6
Joined: Tue Jul 10, 2012 11:43 am

Re: How Can I Tell When an Update Fails?

Post by juliet » Tue Jul 24, 2012 1:36 pm

Hello Steve,

Your statement is correct. If the Save operation produces an error, then the DTO was not successfully saved/updated. If successful, the result will contain the DTO with all corresponding fields.

Please let me know if you have additional questions.

Thanks,
Enterprise Support Analyst
B U L L H O R N
Staffing and Recruiting Software, On Target, On Demand
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
617-478-9126 (main)

Post Reply