Page 1 of 1

Related Table Erroneous Entries

PostPosted: Wed Oct 24, 2012 10:24 am
by simb
Hi Steve and forum members,

I hope someone can shed light on __keys__[id] a hidden field which is passed when submitting a form.

The issue we are facing is that in a related table arrangement, the __keys__[id] at some random point in time do not match the actual id of the table. As a result the related data which gets entered is for a wrong parent record.

Here is the source view of the page before submission:

<input name="__keys__[id]" type="hidden" value="730" />
<input name="-table" type="hidden" value="tbl_application" />
<input name="-relationship" type="hidden" value="trc" />
<input name="-action" type="hidden" value="new_related_record" />
<input name="-table" type="hidden" value="tbl_application" />
<input name="-action" type="hidden" value="new_related_record" />
<input name="-limit" type="hidden" value="200" />
<input name="-cursor" type="hidden" value="202" />
<input name="-skip" type="hidden" value="200" />
<input name="-mode" type="hidden" value="browse" />
<input name="-recordid" type="hidden" value="tbl_application?id=729" />
<input name="-relationship" type="hidden" value="trc" />
<input name="--original_action" type="hidden" value="new_related_record" />
<input name="-query" type="hidden" value="-table=tbl_application&amp;-action=new_related_record&amp;-limit=200&amp;-cursor=202&amp;-skip=200&amp;-mode=list&amp;rfaId=%3D4&amp;status=%3DComplete&amp;-recordid=tbl_application%3Fid%3D729&amp;-relationship=trc" />

The actual value that should have been passed is 729 but what is passed is 730 ( __keys__[id]) and as a result the data gets entered in the wrong parent record. Really scratching my head and there just does not seem to be a logical answer to this - Did not change the code etc, every thing was working just a few days ago and the recurrence of the event is more than can be safely ignored. Currently handling this in beforeInsert when I manually check the values and if they are different, exit gracefully. This happens in all related tables and with admin as well other roles.

Any pointers will be highly appreciated,
Looking forward -
Thanks!

Re: Related Table Erroneous Entries

PostPosted: Fri Oct 26, 2012 9:05 am
by shannah
Can you post some more information. E.g. the relevant relationships.ini definition and table definitions?
Also, what version of Xataface are you using?

Re: Related Table Erroneous Entries

PostPosted: Fri Oct 26, 2012 9:43 am
by simb
Hi Shahnah,

xataface version is 1.3.2

The parent table is "tbl_application" and has "id" as a primary, auto increment field.
The child table is "trc" and has a filed "applicationId" which refrences the parent (tbl_application) id in FK relation ship.
The tables are linked in a one to many arrangement.

The relationship.ini includes:

[trc]
trc.applicationId = "$id"
action:label = Trc
action:order = 2

There are more than 17 active child tables in relationship.ini
The parent as well as child tables include thousand of entries and the application has more than 2000 users.

The issue occurs when multiple "add new related record" tabs are opened at the same time and we try to enter multiple records at the same time.

I have been able to handle the issue by changing the following else block:

else {
$app =& Dataface_Application::getInstance();
$qt =& Dataface_QueryTool::loadResult($app->_currentTable);
return $qt->loadCurrent();
}

-- to:

else {
$app =& Dataface_Application::getInstance();
return $app->getRecord();
}

at around line 180 Dataface/ShortRelatedRecordForm.php

Thanks!

Re: Related Table Erroneous Entries

PostPosted: Fri Oct 26, 2012 9:47 am
by shannah
Thanks for posting this. I'm not sure why this fix works, but I'll look into it. I've add a bug report.
http://bugs.weblite.ca/view.php?id=1167

Re: Related Table Erroneous Entries

PostPosted: Fri Oct 26, 2012 10:29 am
by simb
Thank you Steve - Always appreciate your support and hardwork!