How can i get ID of previous generation

オフライン

Hello im trying to get ID of gen 2 in a variable in Csharp can someone tell me how i can do that?

ID              Gen

1                1

2                2

3                3

4               4

Parents
  • Hi HKhan

    I don't know the contextItem of your method call. Assuming your method call contextItem is part, you can run below code snippet

    Innovator innovator = this.getInnovator();
    string configId = this.getProperty("config_id");
    Item partItem = innovator.newItem("Part","get");
    partItem.setProperty("config_id", configId);
    partItem.setProperty("generation", "0");
    partItem.setAttribute("select", "id,generation");
    partItem.setAttribute("maxRecords", "2");
    partItem.setAttribute("orderBy", "generation DESC");
    partItem.setPropertyCondition("generation", "ge");
    partItem = partItem.apply();
    if(partItem.isError())
    {
    return innovator.newError("Error getting partItem " +partItem.getErrorString());
    }
    if(partItem.getItemCount() > 1)
    {
    return innovator.newResult("ID of Previous Generation is " +partItem.getItemByIndex(1).getID());
    }
    else
    {
    return innovator.newError("Previous Generation does not exist.");
    }

  • 0 オフライン in reply to Gopikrishnan

    can you also tell what partItem.setPropertyCondition("generation", "ge"); does? like what does "ge" mean?

Reply Children