PlasmaTek - Wednesday, January 16, 2013 3:34 AM:
I am currently listing out files from Aras using the .Net API. However, I seem unable to limit the returned files to only the files that are released. I seem to get every iteration of the file. Could anyone assist?
Example code used:
String par = "CC217ECFAF0E45BB80D1CE570DD54877"; Aras.IOM.HttpServerConnection MyConnection; MyConnection = Aras.IOM.IomFactory.CreateHttpServerConnection("myserver/.../InnovatorServer.aspx", "Production", "user", "pass"); MyInnovator = new Aras.IOM.Innovator(MyConnection); String filetypeIds = par + "," + dft + "," + asm; qryItem = results.getItemsByXPath("//Item[@type='File']"); //Aras.IOM.Item item = results.getItemByIndex(0); Many thanks
String dft = "A6F4974401834C56880B6A732D33A0AF";
String asm = "B1F21B3CCF4F44B6960B8A38AECE4E69";
Aras.IOM.Innovator MyInnovator;
Aras.IOM.Item login_result = MyConnection.Login();
if (login_result.isError())
{
Console.WriteLine(login_result.getErrorDetail(), EventLogEntryType.Error);
}
Aras.IOM.Item qryItem = MyInnovator.newItem("File", "get");
qryItem.setAttribute("select", "id,keyed_name,modified_on,item_number,filename,file_type,state,is_released");
qryItem.setProperty("file_type", filetypeIds);
//Released, In Change"- highest revision of same file current_state
//qryItem.setPropertyCondition("state", "Released,In Change");
qryItem.setPropertyCondition("file_type", "in");
Aras.IOM.Item results = qryItem.apply();
int counter = 0;
for (int i = 0; i < qryItem.getItemCount(); i++)
{
Aras.IOM.Item item = results.getItemByIndex(i);
if (item.getType().Equals("File"))
{
String is_released = item.getProperty("is_released").ToString();
if ((is_released != null) && (is_released.Equals("1")))
{
...
}
}
}
Phil - Thursday, January 17, 2013 3:19 PM:
Without getting too much into it...I find that sometimes instead of using the IOM, it is more reliable to use AML. For example..your section of code that is written this way:
-------------------------
Aras.IOM.Item qryItem = MyInnovator.newItem("File", "get");
qryItem.setAttribute("select", "id,keyed_name,modified_on,item_number,filename,file_type,state,is_released");
qryItem.setProperty("file_type", filetypeIds);
//Released, In Change"- highest revision of same file current_state
//qryItem.setPropertyCondition("state", "Released,In Change");
qryItem.setPropertyCondition("file_type", "in");
Aras.IOM.Item results = qryItem.apply();
---------------------------
I would change it to this :
string strAML = "<AML><Item action='get' type='file' select='id,keyed_name,modified_on,item_number,filename,file_type,state,is_released'>" +
"<file_type condition='in'>" + filetypeIds + "</file_type></Item></AML>";
Item result = MyInnovator.applyAML(strAML);
That should get it done for you.
PlasmaTek - Monday, January 21, 2013 5:50 AM:
Hi Phil
Many thanks for taking the time to answer my question. I'm still getting the same result though. ARAS just gives me all the files and the "is_released" property is reported as 1 for every file. I cannot seem to weed out only the geniuine released versions.
Thanks
Colin
vasant - Monday, January 21, 2013 7:00 AM:
Hello Colin,
You can code as per below sample:
String filetypeIds = par + "," + dft + "," + asm;
Aras.IOM.Item qryItem = MyInnovator.newItem("File", "get");
qryItem.setAttribute("select", "id,keyed_name,modified_on,item_number,filename,file_type,state,is_released");
qryItem.setProperty("is_current", "1");
qryItem.setProperty("file_type", filetypeIds);
qryItem.setPropertyCondition("file_type", "in");
Aras.IOM.Item results = qryItem.apply();
Thanks-Vasant
PlasmaTek - Monday, January 21, 2013 7:10 AM:
Hi Vassant
No go I'm afraid, every single file is still returned.
vasant - Monday, January 21, 2013 7:37 AM:
Hi Colin,
Actually file Lifecycle is Default LC, which has only one state "Released". So every file is Released for you.
If you wants to get files which are used under "Document File" then Aras is creating versions of file. And code of last post will gives you latest file.
But if you wants to get the latest released file used as native_file in CAD then try with following code:
Aras.IOM.Item qryItem = MyInnovator.newItem("CAD", "get");
qryItem.setAttribute("select", "id,keyed_name,modified_on,item_number,native_file");
qryItem.setProperty("is_current", "1");
qryItem.setProperty("name", "Test CAD");
Aras.IOM.Item results = qryItem.apply();
Thanks-Vasant