After you create or edit a record, save your changes to the database by following these steps:
The Validate method runs the schema's validation scripts and returns a string containing any validation errors. If this string is not empty, you can use the GetInvalidFieldValues method to return a list of fields that contain data that are not correct. After fixing the values in these fields, you must call Validate again. If the Validate method returns an empty string, there are no more errors.
After you validate the record, and the validation succeeds, you commit your changes to the database by calling the Commit method of the corresponding Entity object.
Reverting your changes: If validation of a record fails, you cannot commit the changes to the database. The safest solution is to revert the record to its original state and report an error. To revert a record, call the Revert method of the Entity object.
Reverting a set of changes returns the record to the state it was in before you called EditEntity. If you revert the changes made to an Entity object created by the BuildEntity method, the record is not created and the data is discarded. IDs associated with records are not recycled. If you revert a record that was made editable by the BuildEntity method, the record is discarded but its visible ID is not discarded so that future records cannot use that ID.
# Modify the record and then commit the changes. $entityObj = $sessionobj->GetEntity("defect","BUGID00000042"); $sessionObj->EditEntity($entityobj,"modify"); # Modify the entity object # Your code should also check for exceptions $status = $entityObj->Validate(); if ($status == ""){ $status = $entityObj->Commit(); if ($status == ""){ # successful commit } else { # check error message } } else { $entityObj->Revert(); } # The entity object is no longer editable.