function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SteveMTCSteveMTC 

Strange Database.Query and Database.Delete behaviour

Hi

 

I am having a bit of a strange problem with the database behaviour at the moment:

 

I have a site where a user can enter info to create one or more records for a custom object (called Applications). These can vary in number and type depending on what the user selects, and are all children of a single parent record, Application Request.

 

Once the user submits the info they are taken to a review page where if they want to change the data before final submission, they can go back to the original page and change anything entered. This works by passing a parameter through the url that indicates whether an edit or creation is taking place, and if it is an edit, the controller queries all applications relating to the application request and presents that information. When they go to submit this edited information the controller deletes the original applications and recreates new ones (even if nothing changes - just seems safer that way).

 

This works fine on a database level, but I am encountering problems when a user goes back to edit an application and for some reason the query to retrieve the related applications either retrieves old records that were deleted when the new info was submitted or doesn't retrieve records that were created. I can see the correct records by querying them through the IDE, but they just don't seem to be appearing when the controller queries the system. I am using the database.query method as I need to query all the fields of the object (to reduce redevelopment when more fields are added in the future) - could this be causing it?

 

This only happens sporadically, and if I refresh the page then it seems to 'catch up' and I can show variables that show the expected query results. The problem is that the part of the page where the user selects the type and amount of records created is a few radioSelects, which on refresh keep the same values rather than be populated by the query results.

 

This seems very bug like to me, but it could just be database.query or database.delete behaviour I don't know about?

 

Has anyone experienced anything like this before? I would show the code but I think it would complicate things even more....

Best Answer chosen by Admin (Salesforce Developers) 
BulentBulent
try the same page with your secure site url. If it works properly then you might need to rethink you page caching parameters
Message Edited by Bulent on 10-19-2009 07:04 PM

All Answers

SteveMTCSteveMTC
Ok, now things are getting even wierder - the list of applications to delete is generated when the page first renders, and is doing as it should (i.e querying and returning the correct records). Now, when I do an action that involves an actionSupport and rerender, the query seems to rerun and then returns old values of deleted records?! What in the name of David Hasslehoff's speedo is going on here?
BulentBulent
try the same page with your secure site url. If it works properly then you might need to rethink you page caching parameters
Message Edited by Bulent on 10-19-2009 07:04 PM
This was selected as the best answer
SteveMTCSteveMTC
Yep, changed the cache to false and it now seems to work like it should - a million thanks!