Frank.Neumann - Tuesday, January 22, 2013 6:48 AM:
I want to create and upload a file using the .NET API - here is a simplified example:
var fileItem = innovator.newItem("File", "add");
fileItem.setProperty("filename", fileName);
fileItem.attachPhysicalFile(pathName);
fileItem.apply();
This executes without errors and creates a file item, but it does not upload the file.
Some entries in the "File" view are missing: File Type and File Size
The Vault does not contain the actual file.
I also tried to capture the generated AML query and to execute it manually - but it leads to the same result:
<AML>
<Item type="File" action="add">
<filename>PaxCapacityZone1 AA.xml</filename>
<actual_filename>D:VS100ProjectsCabin_7CabinModulesA350TestDataFilesRulesPaxCapacityZone1 AA.xml</actual_filename>
<checkedout_path>D:VS100ProjectsCabin_7CabinModulesA350TestDataFilesRules</checkedout_path>
<Relationships>
<Item type="Located" action="add" where="related_id='67BBB9204FE84A8981ED8313049BA06C'">
<related_id>67BBB9204FE84A8981ED8313049BA06C</related_id>
</Item>
</Relationships>
</Item>
</AML>
We use Aras Innovator 9.3 Build 5663.
vasant - Tuesday, January 22, 2013 7:31 AM:
Hi Frank,
Try with below Code:
inn=this.getInnovator();
File=inn.newItem("File","add");
File.setProperty("filename","CIRCLE_ARAS.dwg");
File.setProperty("actual_filename","C:\Working Directory\CIRCLE_ARAS.dwg");
File.setProperty("checkedout_path","C:\Working Directory");
try{
File.attachPhysicalFile("C:\Working Directory\CIRCLE_ARAS.dwg")
}catch(e){alert("Error while Attaching file:"+e);}
Res=File.apply();
return this;
Thanks-Vasant
Frank.Neumann - Wednesday, January 23, 2013 4:30 AM:
Hi Vasant,
thank you for your help. Actually, the following sequence of calls is sufficient:
File.setProperty("filename","CIRCLE_ARAS.dwg");
File.attachPhysicalFile("C:\Working Directory\CIRCLE_ARAS.dwg")
Res = File.apply();
The call to attachPhysicalFile generates the AML statements for setting the actual_filename and the checkedout_path.
My problem was that I called apply() in the frame of a much bigger transaction. Apparently, the attachPhysicalFile() method requires a separate apply.
Frank