This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to create an XML tag that will add multiple objects in one metadata field when importing files using Connections to External Sources/File Sources

Hi,

I'm importing PDF files using the Connections to External Sources/File Sources option.  I have a PDF file and an XML file with the same name and I'm using the "Read from an XML file using an XPath expression" for creating the metadata.  Everything works fine but I've now been asked to import multiple items into the same metadata field.  These are objects that already exist in the system - it seems that this is a requirement.  I've tried lots of ways to do this, e.g. putting a semicolon, comma, pipe, between the two object titles and putting quotes around each object and none of this works.  I've tried adding the xml tag twice on two different lines but it only loads the first one.  Does anyone know how to load more than one object into the same metadata field?  An example of what I'm trying to do is the following:

<invoice>
<invoicenumber>12345</invoicenumber>
<ponumber>P-12345</ponumber>
<vendorid>123</vendorid>
<vendorname>VENDOR, INC.</vendorname>
<podocument>P-12345 - 6/16/2021</podocument>
<podocument>P-12345 - 6/17/2021</podocument>
</invoice>

In this case the first PO Document is added into the metadata field but the second one is ignored.  If I do the following nothing is loaded into the PO Document field.

<invoice>
<invoicenumber>12345</invoicenumber>
<ponumber>P-12345</ponumber>
<vendorid>123</vendorid>
<vendorname>VENDOR, INC.</vendorname>
<podocument>"P-12345 - 6/16/2021" ; "P-12345 - 6/17/2021"</podocument>
</invoice>

Thanks for any help anyone can give!

Susan

Parents
  • Hey Susan! 

    I believe the XML formatting should be something like this:

    <invoice>
         <invoicenumber>12345</invoicenumber>
         <ponumber>P-12345</ponumber>
         <vendorid>123</vendorid>
         <vendorname>VENDOR, INC.</vendorname> 
         <podocuments>
              <podocument>P-12345 - 6/16/2021</podocument>
              <podocument>P-12345 - 6/17/2021</podocument>
         </podocuments>
    </invoice>

Reply
  • Hey Susan! 

    I believe the XML formatting should be something like this:

    <invoice>
         <invoicenumber>12345</invoicenumber>
         <ponumber>P-12345</ponumber>
         <vendorid>123</vendorid>
         <vendorname>VENDOR, INC.</vendorname> 
         <podocuments>
              <podocument>P-12345 - 6/16/2021</podocument>
              <podocument>P-12345 - 6/17/2021</podocument>
         </podocuments>
    </invoice>

Children
  • Hi Tom,

    Thanks for your help.  I just tried the XML formatting that you suggested (I was excited to see if this worked!) and unfortunately it loads the first of the PO Documents but not the second.  I did send this to M-Files support and they say that the M-Files Connections to External Sources/File Sources option is currently unable to do what I want it to do.  Thanks for trying to solve this for me! 

  • Hi Susan,

    I am sure that support are correct (they are generally very good!).  That said, there may be some potential options if you have some scripting experience.

    One option might be to have your PO Documents in a delimited text string inside an XML element (e.g. "<podocument>P-12345 - 6/16/2021;P-12345 - 6/17/2021</podocument>"), and to place that delimited text into a text property.  You could then have some VBScript run when the document is created, parse that delimited text, and populate the multi-select lookup property on the new object.

    If you have some C# skills then another potential option would be to use the open-source XmlImporter sample code that we publish.  I don't believe that it supports specifically the use-case you're after, but it would be fairly simple to modify it to do so (VaultApplication.ImportXmlFile.cs, line 264 would need to be modified to find all matching elements and to iterate over them as appropriate).

    That said, this is a frustrating limitation and I do appreciate that resorting to scripting isn't ideal at all.

    Regards,

    Craig.

  • Hi Craig,

    Thanks for your suggestions.  I don't have any scripting experience but there are other people on our team that do, so I'll pass these suggestions on and see if they can help me implement any of these.

    I appreciate your help!

    Susan