Forum Discussion

lucas's avatar
lucas
Creator II
5 years ago
Solved

checking fields before creating an item

hello, i have created an itemtype, when i create an item of this type the forms contains couples of field. for each couples i need to check if one of the item as a value the other one should too. ...
  • angela's avatar
    angela
    5 years ago

    Simple throw an error inside your onAfterAdd/Update/Version Method. This way you can also give your users some feedback about what they did wrong.

    e.g.

    Innovator inn = this.getInnovator();
    var myprop = this.getProperty("name","");
    if (myprop != "sampleValue")
    {
       return inn.newError("Cannot save item, name is wrong");
    }

    The newError will prevent that your new or updated item will be saved.