How to get the relationship count before the parent itemtype save

Hello everyone,

I need to check that user has added  at least one  relationship before save base on some item types fields, anyone know which event I should use and how to do that? Example is just like the picture below.

Parents
  • Sample is included here,  Add below in OnBeforeAdd/Update server event

    string ValueToFetch=this.getProperty("make_buy","");

    if(value=="your condition) {

    this.fetchRelationships("Relationshipname");

    Item RelationshipsItem=this.getRelationships("Relationshipname");

    int count=RelationshipsItem.getItemCount();

    If (count==0) {

    this.getInnovator().newError("Please add atleast one Document");

    }

    }

    return this;

    .

Reply
  • Sample is included here,  Add below in OnBeforeAdd/Update server event

    string ValueToFetch=this.getProperty("make_buy","");

    if(value=="your condition) {

    this.fetchRelationships("Relationshipname");

    Item RelationshipsItem=this.getRelationships("Relationshipname");

    int count=RelationshipsItem.getItemCount();

    If (count==0) {

    this.getInnovator().newError("Please add atleast one Document");

    }

    }

    return this;

    .

Children