Updates the database with the changes made to the Entity object.
You can call this method only if the Entity object is editable. To make an existing Entity object editable, call the EditEntity method of the Session object. You can use the IsEditable method of the Entity object to determine if you need to revert the commit operation as part of the exception handling. You may not want to revert for all validation failures, and calling the Revert method does not work after a successful Commit (even if it returns a post-notification warning because the entity has already been committed to the database.
On failure, the method may return a string containing an error message or an exception, depending on what causes the failure. For example, the method returns a string containing an error message for failures such as invalid values set for fields. However, the method throws an exception for other failures, such as trying to change an entity that is not in an editable state. Your code should handle both types of potential failures. Pour plus d'informations, voir Contrôle des erreurs et contrôle de validité. The Action commit hook example provides examples of error and exception handling when calling the Commit method.
VBScript
entity.Commit
Perl
$entity->Commit();
VBScript
' Modify the record and then commit the changes. set sessionObj = GetSession set 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 = "" then status = entityObj.Commit if status = "" then ' successful commit else 'check error message end if else entityObj.Revert end if ' The Entity object is no longer editable
Perl
# Modify the record and then commit the changes. $sessionObj = $entity->GetSession(); $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.