Forum Discussion
Changed the code use "get' command and combined it with "Select". Still didn't worked.
Item Man_Part_List = inn.newItem("Manufacturer Part", "get");
Man_Part_List.setAttribute("select","item_number");
Man_Part_List.setAttribute("where", "[Manufacturer_Part].IS_CURRENT= '1'");
Man_Part_List = Man_Part_List.apply();
It should work. I was able to use this one successfully in my test db:
Innovator inn = this.getInnovator();
Item Man_Part_List = inn.newItem("Manufacturer Part", "get");
Man_Part_List.setAttribute("select","item_number");
Man_Part_List.setAttribute("where", "[Manufacturer_Part].IS_CURRENT= '1'");
Man_Part_List = Man_Part_List.apply();
for (int i = 0; i < Man_Part_List.getItemCount(); i++)
{
Item cur_man_part = Man_Part_List.getItemByIndex(i);
string cur_man_part_name = cur_man_part.getProperty("item_number"); //cur_man_part_name always returns NULL
return inn.newResult("My test result: " + cur_man_part_name);
}
---
You liked this answer? Subscribe to my Youtube channel to learn even more about PLM --> PLM Underground on Youtube
- nchagan5 years agoIdeator I
It is weird. I used the same code on my environment and for me it returns NULL.The only change is, am using newError instead of newResult but that should not make any difference.
return inn.newError("My test result: " + cur_man_part_name1);
- angela5 years agoCatalyst II
That´s really weird. Does your "getItemCount()" return the correct number items?
What result do you get, when you directly display the item in an error message?
E.g.
Innovator inn = this.getInnovator();
Item Man_Part_List = inn.newItem("Manufacturer Part", "get");
Man_Part_List.setAttribute("select","item_number");
Man_Part_List.setAttribute("where", "[Manufacturer_Part].IS_CURRENT= '1'");
Man_Part_List = Man_Part_List.apply();
return inn.newError(" " + Man_Part_List);I am little bit confused of your 'where' query. It´s not wrong and should work, I am just curious why you use it. Manufacturer Parts by default are not revised. What happens when you don´t use this filter or replace it with this version, that does the same:
Man_Part_List.setProperty("IS_CURRENT","1");
Is your query part of a bigger query? So for example you also search for Parts and Part AML at the same time?
- nchagan5 years agoIdeator I
Thanks angela for helping me on this. Here are my comments.
1) Does your "getItemCount()" return the correct number items? -- Yes
2) What result do you get, when you directly display the item in an error message? - Attached the screenshot
3) What happens when you don´t use this filter or replace it with this version, that does the same:Man_Part_List.setProperty("IS_CURRENT","1"); -- Tried it. But the results are same. It will still not give any name of the ManufacturerPart - Attached the screenshot. We have changed out Manufacturer parts to have revisions.
4) Is your query part of a bigger query? So for example you also search for Parts and Part AML at the same time? ---No
Thanks,
NC.