i have a custom record and when creating a new ins...
# suitescript
m
i have a custom record and when creating a new instance of this record, I would like to check if the name of the record already exists, ideally when the user has typed into the field and notify the user if the name already exists. alternatively, this alert should appear before saving the record. what's the most efficient way of doing this? right now, I am thinking of loading a saved search and checking if the field value exists.
n
presuming you only want to check this via the UI... You could use a client script to take the field value and perform a quick search to see if you have a result, if one exists put a message to the screen. (and maybe clear the field too?)
m
yep - via UI. so when you sat perform q quick search you mean load up a saved search and do a lookup in the saved search, right?
n
just perform a search where the name == the value being entered.
up to you if you want to rely on a saved search and shoehorn in the value, you sure don;t want to bring back every record and then decide which one matches on name. I'd probably just create the search in code and then there's no reliance on a saved search. One thing to mention if you are checking on EDIT and CREATE just make sure in EDIT that if you get a result back that the record isn't the one you're currently editing 😉
m
ah I see now - dynamically create the search in code, that makes so much more sense.
i would only check on Create as the name field be come disabled