wasSuccessful and getExportException return incorrect output

Document ID : KB000103185
Last Modified Date : 25/06/2018
Show Technical Document Details
Issue:
When an export fails using the ExportObject class, the functions wasSuccessful and getExportException return values that indicate the export was successful.

Sample code:

System.out.println(obj.getExportException());
System.out.println("Success:" + obj.wasSuccessful());

Expected Result:

Could not find the object. It may have been deleted or renamed. 
Success: false

Actual Result:

Null
Success: true
Cause:
A check for getmessagebox()!=null must always follow a sendrequestandwait() call. Evaluating a response when getmessagebox() == null will be working in an undefined condition. 
Resolution:
Add a check for getmessagebox() != null before calling the wasSuccessful() and getExportException() functions. 

Sample code:

if (obj.getMessageBox() != null) {
    System.out.println(obj.getExportException());
    System.out.println(obj.wasSuccessful());
    System.out.println("Export failed");
}
else {
    if (obj.wasSuccessful() == true) {
        System.out.println(obj.getExportException());
        System.out.println("Success");
    }
}