I'm facing this bug when i try to save a form with a MultiFileItem and a foreign key's field filled
What i expect is that when i save a form with a MultiFileItem that contains attachment, they are also saved. But it doesn't happen if another field ,that have a foreign key, is filled.
Steps without foreign key value:
1) Fill title field (ex. Document 1)
2) Add an attachment at the MultiFileItem's field
3)Click on "Save Form"
And it works correctly.
Steps with foreign key value:
1)Fill "title" field (ex. Document 2)
2)Fill "TO:" field
3) Add an attachment at the MultiFileItem's field
4)Click on "Save Form"
And it doesn't work.
So, i tried to debug and i saw that the MultiFIleItem, after save callback, it's cleaned and refilled again, but with undefined value instead of "fakepath value".
ISC_VERSION :
Code to reproduce the bug
these are dummy tables. I tried with mysql and oracle, and the problem happens in both
sql code:
DataSource code:
JS CODE:
In this example i put on the right side two grids in which you can see the results on live.
What i expect is that when i save a form with a MultiFileItem that contains attachment, they are also saved. But it doesn't happen if another field ,that have a foreign key, is filled.
Steps without foreign key value:
1) Fill title field (ex. Document 1)
2) Add an attachment at the MultiFileItem's field
3)Click on "Save Form"
And it works correctly.
Steps with foreign key value:
1)Fill "title" field (ex. Document 2)
2)Fill "TO:" field
3) Add an attachment at the MultiFileItem's field
4)Click on "Save Form"
And it doesn't work.
So, i tried to debug and i saw that the MultiFIleItem, after save callback, it's cleaned and refilled again, but with undefined value instead of "fakepath value".
ISC_VERSION :
- v10.0p_2015-12-10/Evaluation
Code to reproduce the bug
these are dummy tables. I tried with mysql and oracle, and the problem happens in both
sql code:
Code:
CREATE TABLE USERS ( ID INTEGER NOT NULL AUTO_INCREMENT, USERNAME VARCHAR(30), PRIMARY KEY(ID) ); CREATE TABLE COMMUNICATION( ID INTEGER NOT NULL AUTO_INCREMENT, TITLE VARCHAR(45), TO_USER_FK INTEGER, PRIMARY KEY(ID), CONSTRAINT fkUser_ID FOREIGN KEY fkUser_ID (TO_USER_FK) REFERENCES USERS(ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); CREATE TABLE ATTACHMENTS ( ID INTEGER NOT NULL AUTO_INCREMENT, ATTACHMENT blob, ATTACHMENT_DATE_CREATED datetime, ATTACHMENT_FILENAME varchar(30), ATTACHMENT_FILESIZE INTEGER, ID_COMMUNICATION_FK INTEGER, PRIMARY KEY(ID), CONSTRAINT fkCommunication_ID FOREIGN KEY fkCommunication_ID (ID_COMMUNICATION_FK) REFERENCES COMMUNICATION(ID) ON DELETE NO ACTION ON UPDATE NO ACTION); INSERT INTO USERS(USERNAME) VALUES('foo@example.com');
Code:
ATTACHMENTS.ds.xml <DataSource xmlns="http://www.smartclient.com/schema" dropExtraFields="false" dbName="test" tableName="ATTACHMENTS" ID="ATTACHMENTS" serverType="sql" > <fields> <field name="ID" type="sequence" primaryKey="true" hidden="true"/> <field name="ATTACHMENT" type="binary"/> <field name="ID_COMMUNICATION_FK" type="integer" foreignKey="COMMUNICATION.ID" hidden="true"/> <field name="ATTACHMENT_DATE_CREATED" type="creatorTimestamp"/> <field name="ATTACHMENT_FILENAME" type="text"/> <field name="ATTACHMENT_FILESIZE" type="integer"/> </fields> </DataSource> COMMUNICATION.ds.xml <DataSource xmlns="http://www.smartclient.com/schema" dropExtraFields="false" dbName="test" tableName="COMMUNICATION" ID="COMMUNICATION" serverType="sql" > <fields> <field name="ID" type="sequence" primaryKey="true" hidden="true"/> <field name="TITLE" type="text"/> <field name="TO_USER_FK" type="integer" foreignKey="USERS.ID" displayField="USERNAME"/> </fields> </DataSource> USERS.ds.xml <DataSource xmlns="http://www.smartclient.com/schema" dropExtraFields="false" dbName="test" tableName="USERS" ID="USERS" serverType="sql" > <fields> <field name="ID" type="sequence" primaryKey="true" hidden="true"/> <field name="USERNAME" type="text"/> </fields> </DataSource>
Code:
isc.HStack.create({ width: "100%", height: "100%", members: [ isc.VLayout.create({ height: "50%", width: "50%", layoutAlign: "center", align: "center", showResizeBar: true, members: [ isc.DynamicForm.create({ ID: "uploadForm", width: 400, height: 100, dataSource: COMMUNICATION, layoutAlign: "center", fields: [ {name: "TITLE"}, { autoFit: true, name: "TO_USER_FK", title: "TO:" }, { name: "ATTACHMENT", title: "Files", height: 50, editorType: "MultiFileItem", dataSource: ATTACHMENTS }, { name: "saveButton", title: "Save Form", type: "button", click: "uploadForm.saveData()" }, { name: "saveButton", type: "button", title: "Clear Form", click: "uploadForm.editNewRecord()" } ] }) ] }), isc.VLayout.create({ height: "50%", width: "50%", layoutAlign: "center", align: "center", membersMargin: 50, members: [ isc.ListGrid.create({ width: "50%", height: "40%", dataSource: COMMUNICATION, autoFetchData: true, layoutAlign: "center" }), isc.ListGrid.create({ width: "50%", height: "40%", dataSource: ATTACHMENTS, autoFetchData: true, layoutAlign: "center" }) ] }) ] });
In this example i put on the right side two grids in which you can see the results on live.
Comment