Deleting/editing records (answersets and answers) + pre-populate from form/field data

Permalink Browser Info Environment
Hi,

I'm still learning about AF, I really like what I have learnt so far and am hoping to get answers to the following questions to help me understand if I can use/integrate AF as part of an upcoming project. Thanks in advance.

1. I can see when an edit occurs that the original record in the answerset table gets its isDeleted field set to 1 and its newASID field set to the value of a newly created record whose asID is equal to the newASID value just mentioned. This new answerset record appears to be essentially a duplicate of the original one aside from those 2 changes (plus editCode and time stamping). In addition a whole new set of answers (records) corresponding to the newASID value is cloned into the answers table and it is these new records that exhibit the edits in the actual data. The old set of answers (records) corresponding to the original asID remain too.

Can you please explain why newASID and this cloning of answerset and answer records occurs when editing a record? And is there a simple option in the form setup to stop this so that only 1 answerset record and the corresponding set of answer records exist for a form submission no matter how many times it is edited (submitted)? If not how and when do the outdated answerset and answer records get removed? Perhaps this is related to approving records? I hope I'm not missing something simple and that records can be automatically approved on submission by using AF C5 GUI options so that there is only ever only 1 answerset record and 1 group of corresponding answer records (even on many edits/submissions), ie, the existing records get updated rather than cloning.

2. In a similar fashion I can see that when a record is deleted its isDeleted field is set to 1 in the answerset table and that seems to be all that happens, ie, the answer set record and the corresponding group of answers (records) in the answers table remain. Clearly, DD must be inspecting the isDeleted field value as my template on the front end knows that a record was deleted as it no longer displays.

Can I ask when is the data actually removed from the answerset and answers tables after a record is deleted? Again I'm probably missing something simple! But, it would be awesome if I could get an answer so that I can better understand how AF and DD are working.

3. Can I also please get some indication as to what files would require change to adjust the "auto populate based on form and then field data" option such that on the front end the drop down (that gets auto populated) values are filtered by the current registered users group/attributes. For example, say you had a form that held shop names and details including the shops state. Then in another form you had a drop down auto populated with the store names (from the first form) such that the list of available shop names is limited to just those shops that are in the same state as the current registered user using this second form. I am assuming that the current registered user would already be in a group that identifies their state (or have an attribute that tracks the state).

Again, thanks for you time.

Regards,
Ben

Type: Discussion
Status: New
whitecliffs
View Replies:
jgarcia replied on at Permalink Reply
jgarcia
The short answer to all of your questions is that I'd like to at some point add a versioning/restore deleted records feature.

I can't really answer all of this here because it would take a LONG time to explain all of the theory about why all of this is coded the way it is, but I'll do my best to give a general answer that still addresses your concerns.

1. First, no - there's not a way to prevent the duplication of the record (I will use record and answer set synonymously). Currently, the old records never get removed, but I am looking at a way to purge old answer sets. Or if you're really concerned with this you can just do "DELETE FROM sixeightformsAnswerSets WHERE isDeleted = 1." This has never been much of an issue for me though. I've got a site that has 1,000's of fairly lengthy records and the answer sets table is still only using 6MB and the answers table is using 7MB.

2. Again, it's not removed at any point, but this has never been an issue before.

3. You'd need to look in models/field.php for this. Specifically, the getOptions() function.
whitecliffs replied on at Permalink Reply
whitecliffs
Hi,

Thanks for the helpful answers and such a quick response it really is very much appreciated!

I must also say I really like how well coded and thought out both AF and DD are.

I hope that with a few smallish overrides (that a carefully separated out from the AF and DD core) that I can build a modified solution and also be able to carefully update to future releases after re-testing any overrides that are in place.

Thanks again,
Ben

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.