Hello I'm currently trying to build a method to create parts from csv files selected by the user. I'm having issues with accessing the fileObject data which i need to then create my parts. I've tried different ways to read the file but it hasn't been succesfull.
here is my code:
var innovator = new Innovator();
var vlt = top.aras.vault;
alert("avant selectfile");
vlt.selectFile().then(function (fileObject)
{
read = new FileReader(); the part i'm having troubles with
//read.readAsText(fileObject);
reader.onload = function(){read.readAsText(fileObject);}
var fileContents= read.results;
var rows =fileContents.split("\n");
alert("apres rows split");
alert(rows[0]);
var i;
for (i = 0; i < rows.length(); i++)
{
//alert("entree n°"+ i+"dans la boucle");
var parts_to_add =rows[i].split(";");
alert(parts_to_add);
var partItem = innovator.newItem("Part","add");
partItem.setProperty("item_number", "test");
var Name =parts_to_add[0];
partItem.setProperty("name", Name);
var desc = parts_to_add[1];
partItem.setProperty("description", desc);
var resultItem = partItem.apply();
}
});
If you have any solution it would be greatly apreciated.
Thanks.
Lucas