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