Forum Discussion

gktcs12's avatar
gktcs12
Ideator I
6 years ago

Uploading Files

Hi

I was trying to create a file and add to document item type using an AML query but getting File Item cannot be added

<AML>
<Item type="Document" action="add">
<item_number>TEST</item_number>
<name>Hi</name>
<Relationships>
<Item type="Document File" action="add">
<related_id>
<Item type="File" action="add">
<filename>1.txt</filename>
<checkedout_path>C:\Backup\1\1.txt</checkedout_path>
<actual_filename>1.txt</actual_filename>
<file_type>3F3FCF1E77CB48F384F1A1FADD5F45E4</file_type>
<Relationships>
<Item type="Located" action="add">
<related_id>67BBB9204FE84A8981ED8313049BA06C</related_id>
</Item>
</Relationships>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
</AML>

Could you please help on this issue

6 Replies

  • I know this is an old thread but for anyone in the future looking for how to add File Items via AML, here is how I was able to get it to work in Aras v12SP18:

        <Item type='File' action='add' id='New32GUID'>
          <actual_filename>C:\Path\to\MyFile\filename.pdf</actual_filename>
          <checkedout_path>C:\Path\to\MyFile</checkedout_path>
          <filename>filename.pdf</filename>
          <Relationships>
            <Item type='Located' action='add'>
              <related_id>32GUIDofVaultItemType</related_id>
            </Item>
          </Relationships>
        </Item>

    The key for me to get past the "File Item cannot be added" error was to ensure the "id" attribute in the beginning had a new unique 32 character GUID.

  • Hi,

    First you have to create file in Aras and then attach that to Document using File Id.

    Create file : 
    Item file = inn.newItem("File", "add");
    file.attachPhysicalFile("C:\\Backup\\1\\1.txt");
    file.setProperty("filename", "1.txt");
    file = file.apply();

    string fileId = file.getID();

    Then add file to relationship of Document : 

    <AML>
    <Item type="Document" action="add">
    <item_number>TEST</item_number>
    <name>Hi</name>
    <Relationships>
    <Item type="Document File" action="add">
    <related_id>fileId</related_id>
    </Item>
    </Relationships>
    </Item>
    </AML>

    Thanks

    • gktcs12's avatar
      gktcs12
      Ideator I

      Hi

      Thanks for the reply. I'm aware of this approach using the IOM. But, I wanna do both in AML in one query.

      Thank You

      • Jayrajvh's avatar
        Jayrajvh
        Creator II

        Same issue I have. I think there is some change in ARAS behaviour of file handling. I have ARAS 12 and simple file upload with Document or without document is failing when I try AML way. Same thing works fine using API.