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.
i had an idea of using a method on before add, check if the couples respect the rule i want and if not i want to cancel the creation of the part and have the user fix the missing value.
let me know if you think of a beter way or if u know how to cancel the creation of an item on an on before add event.
thanks.
Lucas
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.