Initializes attributes with default values and validates that required values exist.
Syntax
bool initAndValidateAttributes();
Return values
Returns TRUE if after processing default values if all required attributes have been set (have non-null values). If a required value has not been set and there is no default value specified for the attribute in the business object definition, returns FALSE.
Notes
The initAndValidateAttributes() method has two purposes:
In case of failure, no value exists for some attributes (those without default values) after initAndValidateAttributes() finishes default-value processing. You might want to code your connector's application-specific component to catch this exception and return BON_FAIL.
The initAndValidateAttributes() method loops through every attribute in all levels of a business object and determines the following:
If an attribute is required and UseDefaults is true, initAndValidateAttributes() sets the value of any unset attribute to its default value. If the attribute does not have a default value, initAndValidateAttributes() returns FALSE.
The initAndValidateAttributes() method is usually called from the business-object-handler doVerbFor() method to ensure that required attributes have values before a Create operation is performed in an application. In the doVerbFor() method, you can call initAndValidateAttributes() for the Create verb. You can also call it for the Update verb, before it performs a Create.
To use initAndValidateAttributes(), you must also do the following:
Examples
int ExampleBOHandler::doVerbFor(BusinessObject &theObj, ReturnStatusDescriptor *rtnStatusMsg) { int status = BON_SUCCESS; // Determine the verb of the incoming business object char *verb = theObj.getVerb(); if (strcmp(verb, CREATE) == 0) { if (!theObj->initAndValidateAttributes()) return BON_FAIL; } else ...