Validation

Hello, I have written method to validate the length of Item_id to 20. But there is error while attaching this method to Itemtype.Whwre should I attached this method on client event,server event,action or form events?? var inno = this.getInnovator(); var ItemId = this.getProperty("_item_id"); if (ItemId == null) { return inno.newError("Please provide a _item_id"); } if (ItemId.Length != 20) { return inno.newError("_item_id needs to be 20 characters."); }
Parents
  • Hi Angela, I think it makes the most sense to attach this Method to onBeforeAdd and onBeforeUpdate Server Events to ensure that no matter how the item gets added, this check for the length of the item_id is performed. Additionally, this kind of check can also be accomplished by specifying a Pattern for the item_id property. You can find more information about Patterns on the "Entering ItemType Properties" of the Just Ask Innovator help page. For string properties, you can specify a regular expression to match the string by. In your case, you could use a regular expression like [a-zA-Z0-9]{20} which will verify that the string is exactly 20 characters and contains only alphanumeric characters. Chris ___________________________________ Christopher Gillis Aras Labs Software Engineer
Reply
  • Hi Angela, I think it makes the most sense to attach this Method to onBeforeAdd and onBeforeUpdate Server Events to ensure that no matter how the item gets added, this check for the length of the item_id is performed. Additionally, this kind of check can also be accomplished by specifying a Pattern for the item_id property. You can find more information about Patterns on the "Entering ItemType Properties" of the Just Ask Innovator help page. For string properties, you can specify a regular expression to match the string by. In your case, you could use a regular expression like [a-zA-Z0-9]{20} which will verify that the string is exactly 20 characters and contains only alphanumeric characters. Chris ___________________________________ Christopher Gillis Aras Labs Software Engineer
Children
No Data