Skip to main content

Hi,

As described here that you can have multiple attachments in Nintex Forms for Lists. One of them should be the Default Control.

https://community.nintex.com/community/tech-blog/blog/2015/07/30/multiple-attachments-in-a-single-form

I have designed a form with three Attachment Controls for my List. I want to know which file attachment is connected to my first Attachment Control, which file attachment is connected to second and third attachment control. I want to get them via CMOS. Is there way find it out? Do you save the relationship between between file attachment and Nintex attachment control in SharePoint?

Your quick response in this regard will be highly appreciated.

Regards.

Aftab Ahmad

Here is similar topic 

Does this help?


Hi Marian,

Thank you for the answer. It has solved my problem happy.png

I have another question related to this. Instead of read the data from FormData, now I want to create items and add attachments by CMOS C# and I want that my attachments bind to Nintex attachment controls. I have tried to put attachment names in FormData Xml but it doesn't work.

Your quick response in this regard will be highly appreciated.

Regards.

Aftab Ahmad


have you uploaded attachment to the list item as well?

I've tested it manually myself - uploaded manually a file to item's attachemnt folder. checked the item - attachment showed under default attachemnt control. updated formdata column to assign file to another control and when checked the item once again it showed under this other control.

so I would say it should work with CSOM as well, if done correctly.


Hi Marian,

is it possible for you to share your code here, how you update the FormData field? If I update the FormData using the my code further below, it gives me following encoding error when I try to open the form.

System.Xml.XmlException: The encoding in the declaration 'utf-8' does not match the encoding of the document 'utf-16LE'.  
 at System.Xml.EncodingStreamWrapper.ThrowEncodingMismatch(String declEnc, String docEnc)   
 at System.Xml.EncodingStreamWrapper.CheckUTF8DeclarationEncoding(Byted] buffer, Int32 offset, Int32 count, SupportedEncoding e, SupportedEncoding expectedEnc)   
 at System.Xml.EncodingStreamWrapper..ctor(Stream stream, Encoding encoding)   
 at System.Xml.XmlUTF8TextReader.SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)   
 at System.Runtime.Serialization.XmlObjectSerializer.ReadObject(Stream stream)   
 at Nintex.Forms.NfUtilities.DeserializeObjectWithDataContractSerializer(String xml)   
 at Nintex.Forms.NfUtilities.DeserializeObject(String xml, SerializationType method)   
 at Nintex.Forms.SharePoint.Helper.GetPersistedFormData(SPContext itemContext, Nullable`1 versionNo)   
 at Nintex.Forms.SharePoint.Helper.GetContextData(String formXml, SPContext itemContext, Nullable`1 versionNo)   
 at Nintex.Workflow.Forms.ControlTemplates.ListForm.InitialiseForm(Boolean hasEnterpriseLicense)   
 at Nintex.Workflow.Forms.ControlTemplates.ListForm.OnInit(EventArgs e)   
 at System.Web.UI.Control.InitRecursive(Control namingContainer)   
 at System.Web.UI.Control.InitRecursive(Control namingContainer)   
 at System.Web.UI.Control.AddedControl(Control control, Int32 index)   
 at Microsoft.SharePoint.WebPartPages.ListFormWebPart.CreateChildControls()   
 at System.Web.UI.Control.EnsureChildControls()   
 at Microsoft.SharePoint.WebPartPages.WebPart.get_WebPartMenu()   
 at Microsoft.SharePoint.WebPartPages.ListFormWebPart.CreateWebPartMenu()   
 at Microsoft.SharePoint.WebPartPages.WebPart.OnWebPartMenuCreate(Object sender, EventArgs s)   
 at System.Web.UI.Control.OnLoad(EventArgs e)   
 at Microsoft.SharePoint.WebPartPages.ListFormWebPart.OnLoad(EventArgs e)   
 at System.Web.UI.Control.LoadRecursive()   
 at System.Web.UI.Control.LoadRecursive()   
 at System.Web.UI.Control.LoadRecursive()   
 at System.Web.UI.Control.LoadRecursive()   
 at System.Web.UI.Control.LoadRecursive()   
 at System.Web.UI.Control.LoadRecursive()   
 at System.Web.UI.Control.LoadRecursive()   

My code is here

if (fileList.Count > 0)
{
       string formDataXml = null;
       formDataXml = "<?xml version=""1.0"" encoding=""utf-8""?>" +
                "<FormVariables>" +
                "<Adressenummer type=""System.String"">Ny leveringsadresse</Adressenummer>" +
                "<hiddenTxtBox type=""System.String"">2</hiddenTxtBox>" +
                "<NewAddressVisible type=""System.String"">0</NewAddressVisible>" +
                "<dc23674e-e25b-4190-81bc-5d4368379ea9 type=""System.String"">Ny leveringsadresse</dc23674e-e25b-4190-81bc-5d4368379ea9>" +
                "<_x0039_fc83301-92e8-426f-b8ae-4afa0017b3df type=""System.String""></_x0039_fc83301-92e8-426f-b8ae-4afa0017b3df>" +
                "<_x0032_9f2c31c-612b-457d-bc8c-0d54212c5f70 type=""System.String""></_x0032_9f2c31c-612b-457d-bc8c-0d54212c5f70>" +
                "<Picture1 type=""System.String""></Picture1>" +
                "<Picture2 type =""System.String""></Picture2>" +
                "<Picture3 type =""System.String""></Picture3>" +
                "<Picture4 type =""System.String""></Picture4>" +
                "<Picture5 type =""System.String""></Picture5>" +
                "<Picture6 type =""System.String""></Picture6>" +
                "<Receipt type =""System.String""></Receipt>" +
                "<OtherDocuments type =""System.String""></OtherDocuments>" +
                "</FormVariables>";
       XmlDocument formDataDocument = new XmlDocument();
       formDataDocument.LoadXml(formDataXml);
       XmlNode xmlNode = null;
       for (int j = 0; j < fileList.Count; j++)
       {
        xmlNode = null;
        switch (j)
        {
         case 0:
          xmlNode = formDataDocument.SelectSingleNode("//Picture1");
          break;
         case 1:
          xmlNode = formDataDocument.SelectSingleNode("//Picture2");
          break;
         case 2:
          xmlNode = formDataDocument.SelectSingleNode("//Picture3");
          break;
         case 3:
          xmlNode = formDataDocument.SelectSingleNode("//Picture4");
          break;
         case 4:
          xmlNode = formDataDocument.SelectSingleNode("//Picture5");
          break;
         case 5:
          xmlNode = formDataDocument.SelectSingleNode("//Picture6");
          break;
         case 6:
          xmlNode = formDataDocument.SelectSingleNode("//OtherDocuments");
          break;
         default:
          break;
        }
        if (xmlNode != null)
         xmlNode.InnerText = fileList;
       }
       listItem>"FormData"] = formDataDocument.OuterXml;
       listItem.Update();
       clientContext.ExecuteQuery();
 }

Best regards.

Aftab Ahmad


as I've written, I haven't written any C#  code, I just made kind of manual test, whether change of attachment control element in FormData out of nintex is accepted.

to make an update of FormData XML I used 'Update XML' workflow action.

as per your problem, I just guess your variables are by some default in different utf format then utf8, but you declare formdata to be utf8.

so either try to declare expected unicode encoding in formdata (not sure whether it will work, though) or retype your variables to be in utf8


Hi Marian,

Ok. Thank you for the help.

Best Regards.

Aftab Ahmad


Reply