Forum Discussion

nchagan's avatar
nchagan
Ideator I
5 years ago

Getproperty() function returns only Null Value

Hello,

I am facing an issue while developing a server side C# method. My method supposed to pull up all the Manufacturer Parts from the table and iterate through them checking them for a condition. If the condition is met, it should return an error.

I was able to retrieve the Manufacturer Part list and iterate over them. However when I am trying to get the value of a property of the Manufacturer Part, it always returns Null.

***********************************************************************************************

Item Man_Part_List = inn.newItem("Manufacturer Part");
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

   if (cur_man_part_name == part_number)
   {
    return this.getInnovator().newError("Manufacturer Part with same name already exist" );
    count = count + 1;
   }
   
 }

***********************************************************************************************

Thanks,

NC.

7 Replies

  • I assume you just get the very plain items without properties. Use the "get" command and combine it with and combine it with a "select" to reduce server load.

    Item Man_Part_List = inn.newItem("Manufacturer Part","get");
    Man_Part_List.setAttribute("select","item_number");

    ---

    You liked this answer? Subscribe to my Youtube channel to learn even more about PLM --> PLM Underground on Youtube

    • nchagan's avatar
      nchagan
      Ideator I

      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();

      • angela's avatar
        angela
        Catalyst II

        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