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

Parents
  • 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

Reply
  • 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

Children