0

I have a VF page which dynamically inserts records into a custom object. To debug the problem and ensure the records have been successfully, I reloaded the inserted records after the insertion. The records were there and could be reloaded into another variable. However, I cannot find the records in the object using Cloudingo Studio. I have also tried to retrieve the previous records by relaunching the VF page again and they were found no longer there. It seems that the records inserted have their lifespan only within the current page. But no DML exception is caught and no rollback has ever been executed manually. Is there anybody can enlighten me on the problem? Thanks.

Sample code likes this:

try {
  Database.insert(recordRow);
}
catch {
  return null;
}

List<Issue__c> readAgain = [SELECT Name FROM Issue__c WHERE Id =: recordRow.Id LIMIT 1];
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, readAgain[0].Name));

1 Answer 1

1

It looks like the transaction containing the changes is not being committed. So while your code can see the changes, at no point in time are the changes made permanent and visible to other requests. (Articles like Isolation (database systems) provide some insight into what is going on internally in Salesforce.)

You say that no DML exception is caught. Do you have code like this:

try {
    Database.insert(recordRow);
} catch (DMLException e) {
    // Do something with the exception, don't just ignore it
}

or this:

try {
    Database.insert(recordRow);
} catch (Exception e) {
    // Do something with the exception, don't just ignore it
}

(The code in your question is unclear.)

Bottom line is that you will need to figure out what the problem is by examining the data in the DmlException that is (probably thrown) from the insert.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .