AnsweredAssumed Answered

Script to check if a record exists

Question asked by BenjaminLea on Feb 15, 2011
Latest reply on Feb 15, 2011 by BenjaminLea


Script to check if a record exists


I have a table of categories and subcategories that are used to create value lists for another table of items.  An example of the table is below.

Category Subcategory
Office Equipment Books
Office Equipment Desk Accessories
Information Technology Laptops
Information Technology Monitors
Information Technology PoS Machines
Bakery Area Mixers

The subcategory value list is a conditional value list, so for example if an item has "Office Equipment" chosen as its category, it will only list the choices "Books" and "Desk Accessories" as subcategories.

On the Item form I have two edit boxes that auto-complete from these two value lists.  What I want them to do is when text is entered into these boxes, they trigger an OnObjectSave event to run a script.  I want the script to check the ItemType table (the one described above) to see if the entered pair exists in the table, and if it doesn't, create it.  This way if a new item is created that goes in the same category/subcategory, it will autocomplete it from the value in the ItemType table.

I've done some basic scripting before, but I don't know how to make this check happen.

Sorry for the large amount of information, I'm hoping the more info I provide the clearer my intent is.  Thank you in advance for your help!