select class on Extended Classification

Former Member
Former Member
When adding a new Part, and by default extended classifications are not selected, is there a way to automatically select classes or all classes of  the extended classifications for a new part when the new part form opens?
Parents
  • Hi fdxu168, I came accross your post as I currently also work with extended classification. I think your use case can be solved with a Method. xClasses are linked to Parts like this: PART -> Relationship PART_XCLASS --> Related Item XCLASS (e.g. class 'Resistor') I think it´s possible to add the PART_XCLASS relationship with an onBeforeAdd/onAfterAdd Method.
  • 0 オフライン in reply to AngelaIp

     Hi Angelalp, I was searching the exact same solution and found your answer.
    I tried to do this by kick the Method with onBeforeAdd or by AML, but It didn't worked to me.
    Do you have any further info on this topic?

    my method

    Innovator inn = this.getInnovator();
    this.setAction("edit");
    Item xclass = inn.newItem("xClass","get");
    xclass.setProperty("id","F55659D7906F4E3A89767FEEFF1913C0");
    xclass = xclass.apply();
    Item rel = this.createRelationship("y_ext_xClass","add");
    rel.setRelatedItem(xclass);
    return this;

    and I got this

    No items of type 'y_ext_xClass' found using the criteria:
    <Item type="y_ext_xClass" id="6BFA1DD7EC1B4AB19C7ACAF59AE8C5C8" serverEvents="1" select="*[is_not_null()]" />

Reply
  • 0 オフライン in reply to AngelaIp

     Hi Angelalp, I was searching the exact same solution and found your answer.
    I tried to do this by kick the Method with onBeforeAdd or by AML, but It didn't worked to me.
    Do you have any further info on this topic?

    my method

    Innovator inn = this.getInnovator();
    this.setAction("edit");
    Item xclass = inn.newItem("xClass","get");
    xclass.setProperty("id","F55659D7906F4E3A89767FEEFF1913C0");
    xclass = xclass.apply();
    Item rel = this.createRelationship("y_ext_xClass","add");
    rel.setRelatedItem(xclass);
    return this;

    and I got this

    No items of type 'y_ext_xClass' found using the criteria:
    <Item type="y_ext_xClass" id="6BFA1DD7EC1B4AB19C7ACAF59AE8C5C8" serverEvents="1" select="*[is_not_null()]" />

Children
  • Your query in general is a bit confusing :). Your "createRelationship" happens after apply(). And you do the apply() on your xClass item and not at the item you want to edit.

    I haven´t tested this one, but I think it worked somehow like this:

    this.setAction("edit");
    Item xyz_xclass= this.createRelationship("xyz_xClass", "add");
    Item xclass= xyz_xclass.createRelatedItem("xClass", "get");
    xclass.setProperty("id","123");
    Item res = this.apply();

    But I recommend that you check the official documentation. There is a guide regarding xClasses with many samples.

    BTW: If you use thumbnails, I would be happy for additional feedback regarding this topic! Thanks!

     Multiple sessions created for trivial actions like "edit". What can be the reason?

  • 0 オフライン in reply to AngelaIp

    Thanks a lot for responding. It works.

    Innovator inn = this.getInnovator();
    this.setAction("get");
    this.setAttribute("levels","1");
    Item temp = this.apply();
    Item rel = temp.getRelationships("z_part_xClass");
    int c = rel.getItemCount();
    if(c==0){
      this.setAction("edit");
      Item xyz_xclass= this.createRelationship("z_part_xClass", "add");
      Item xclass= xyz_xclass.createRelatedItem("xClass", "get");
      xclass.setProperty("id","82B56E7EC88B4CDA87ABAE435A18D72D");
      Item res = this.apply();
    }
    
    return this;

    I am also looking for a solution to preset it when create a new Item. (My customer want the xClass be selected at beginning)

    do you think it works with client method?

    BTW: Sorry I don't have answer about your question.