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."); }
  • 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
  • Hello, I tried but there is error called "The Method tyep javascript not currently supported"
  • Hi Angela, Server Events will only accept Methods that are written in C# or VB. There is a dropdown on the Method form that will allow you to change your Method from JavaScript to C#. You may also need to update the code to compile in C#. After saving your method as C#, you should be able to attach it to a Server Event without issue. Chris ________________________________ Christopher Gillis Aras Labs Software Engineer