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.
|Office Equipment||Desk Accessories|
|Information Technology||PoS Machines|
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!