Data is saving alternatively into form library while using infopath submit button with attachment - InfoPath Dev
in

InfoPath Dev

Data is saving alternatively into form library while using infopath submit button with attachment

Last post 08-04-2012 07:27 AM by Iranna. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 08-04-2012 07:27 AM

    • Iranna
    • Not Ranked
    • Joined on 08-04-2012
    • Posts 1

    Data is saving alternatively into form library while using infopath submit button with attachment

    Hi,
    i am saving an attachment to document library in FormEvents_Submit event of infopath 2010 and also submitting to form library.
     public void FormEvents_Submit(object sender, SubmitEventArgs e)
            {
                // Decode the InfoPath file attachment
                InfoPathAttachmentDecoder dec = new InfoPathAttachmentDecoder(attachmentValue);
                string fileName = dec.Filename;
                byte[] data = dec.DecodedAttachment;
                // Add the file to a document library
                using (SPSite site = new SPSite(siteURL))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        web.AllowUnsafeUpdates = true;
                        SPFolder docLib = web.GetFolder(web.Url + libraryName);
                        SPFile file = docLib.Files.Add(fileName, data, true);
                        SPListItem item = file.Item;
                        item["Deal ID"] = strDealID;
                        item["Stage"] = currentStage;
                        item.Update();
                        web.AllowUnsafeUpdates = false;
                        web.Close();
                    }
                    site.Close();
                }
           

    DataConnection spConn = DataConnections["Main Submit"];
                    spConn.Execute();
    }

    the attachment and form library values are  saving correctly.

    Problem is when user clicks second time to add new item in form library the data is not saved in form library.But attachment is saved in document library.

    so third time both data is saved to form library and attachment is saved in document library.

    but fourth time form library the data is not saved in from  library.But attachment is saved in document library.

    so alternatively data is saving into form library.but without attchemnt data will be saved every time to form libray.

    Please help

     Regards,
    Iranna G

    Filed under:
Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.