Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    [BUG] Cannot save File via MultiFileItem when the form have ForeignKey

    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 :
    1. v10.0p_2015-12-10/Evaluation
    OS and Browser: Google Chrome Version 47.0.2526.111 m (64-bit)


    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');
    DataSource code:
    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>
    JS CODE:
    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.
    Last edited by simokris; 19 Jan 2016, 04:01.

    #2
    Can you see if you can reproduce this with the latest 10.0 or 10.1 version? We just fixed a bug in late December (after your build date) that involved cases where MultiFileItem should or shouldn't clear form values.

    Comment


      #3
      Originally posted by Isomorphic View Post
      Can you see if you can reproduce this with the latest 10.0 or 10.1 version? We just fixed a bug in late December (after your build date) that involved cases where MultiFileItem should or shouldn't clear form values.
      Ok, I tried with the latest version (10.0p_2016-19-01/Evaluation and 10.1p_2016-19-01/Evaluation) but the problem is the same.

      Comment


        #4
        any news?

        Comment


          #5
          Hi isomorphic, any news on this?

          Comment


            #6
            Hi isomorphic, any news on this?

            Comment


              #7
              This is queued to be looked at, but assuming there is a bug here, it's very obscure (just a few users affected at most), and the test case requires a bunch of setup effort, so this issue hasn't been near the top of the queue.

              If you need prompt attention to this or other issues, please purchase a Support contract.

              Comment


                #8
                This reached the top of the stack sooner than anticipated.
                We've made a change to 10.0, 10.1 and 11.0 branches which should address this issue.
                Please try the next nightly build, dated Feb 10 or above

                Regards
                Isomorphic Software

                Comment

                Working...
                X