yoni_k - Thursday, August 18, 2011 4:04 AM:
i have tried to attach a pdf file to an item and everything worked just fine once ive added another filr (same code diff variables diff path) it seem to "forgot" the last file and did not attach the new one either...ideas?
Brian - Sunday, August 21, 2011 5:28 AM:
Hi Yoni,
I'm not sure I understand your question properly.
However, yes you can have more than one file attached to a document. As you can have more than one document attached to a part.
It seems you may have done something wrong with you example but I'm not sure what.
Hope this helps.
Brian.
yoni_k - Monday, August 22, 2011 12:49 AM:
Hi Brian,
First of all tnx for your answer, though im quite sure my method should run just fine and just to be clearer
1) im attaching a pdf file to an item
2) using the same method im attaching a dsn file to the same item
3) ive checked for each of them separately and alone they work just fine
4) once im trying to run both of them together i dosent attach them or just dosent disply them on the "Structure Browser"(<== on the item menu)
nor on the "Where Used" (<==on the filesdocs menu)
tnx again for your help,
Yoni.
Brian - Monday, August 22, 2011 12:56 AM:
Hi Yoni,
Can you post the code you are using?
Thanks,
Brian.
yoni_k - Monday, August 22, 2011 3:17 AM:
Tnx for your quick response Brian,
thats the complete code for adding the two files:
// load a pdf file
alert("Please select a pdf file");
var pdfFilePath = top.aras.vault.SelectFile();
// use those for || var x = pdfFilePath.lastIndexOf('.') + 1;
// validation || var pdfFileType = pdfFilePath.substring(x,pdfFilePath.length);
// create the document item
var pdfItem = this.newItem("Document","add");
pdfItem.setProperty("item_number",parent_number+".pdf");
// Create the File item and set the path to the file.
var pdfFile = this.newItem("File","add");
pdfFile.setFileName(pdfFilePath);
// Create the relationship between the Document and File
var relPdfDocToFile = this.newItem("Document File","add");
pdfItem.addRelationship(relPdfDocToFile);
relPdfDocToFile.setRelatedItem(pdfFile);
var attachPdf = pdfItem.apply();
if (attachPdf.isError()) {
top.aras.AlertError(attachPdf.getErrorDetail());
} else {
// Show the new Document
top.aras.uiShowItemEx(attachPdf.getItemByIndex(0).node, 'tab view', true);
}
// load a Dsn file
alert("Please select a Dsn file");
var dsnFilePath = top.aras.vault.SelectFile();
// use those for|| var y = dsnFilePath.lastIndexOf('.') + 1;
// validation || var dsnFileType = dsnFilePath.substring(y,dsnFilePath.length);
// create the document item
var dsnItem = this.newItem("Document","add");
dsnItem.setProperty("item_number",parent_number+".DSN");
// Create the File item and set the path to the file.
var dsnFile = this.newItem("File","add");
dsnFile.setFileName(dsnFilePath);
// Create the relationship between the Document and File
var relDsnDocToFile = this.newItem("Document File","add");
dsnItem.addRelationship(relDsnDocToFile);
relDsnDocToFile.setRelatedItem(dsnFile);
var attachDsn = dsnItem.apply();
if (attachDsn.isError()) {
top.aras.AlertError(attachDsn.getErrorDetail());
} else {
// Show the new Document
top.aras.uiShowItemEx(attachDsn.getItemByIndex(0).node, 'tab view', true);
}
Best regards,
Yoni.