hi all - We have a SuiteApp deployed to some clien...
# suitescript
c
hi all - We have a SuiteApp deployed to some clients. I have a request to modify the search to include a custom field the client has on their vendor form. Just wondering if there is a good way to handle those? If columns don’t exist we of course get the infamous SSS_INVALID_SRCH_COL error. Wondering if there is a best practice for handling those types of things? Or, perhaps I am missing something obvious.
b
create some sort of configuration so your search can lookup which field its supposed to use
c
Would you mind giving me an idea of what you mean here? I appreciate the response. I am likely not as experienced with NetSuite as others on this channel.
b
you need to setup something to allow your users to choose which column to search
and write script logic to use that configuration
the common methods of doing this are Script Parameters: https://system.na0.netsuite.com/app/help/helpcenter.nl?fid=part_1542289448.html
or a custom record which has a field that the user sets and which your script looks up
c
I currently use script parameters at the Company level. Which are used throughout the RESTlet’s. But, this particular field was added to the Vendor form by the client. Now they want the SuiteApp to use the field they added. Does what your mentioning help solve that?
If we have other clients making similar requests to use their custom fields; I wasn’t sure how to deal with that particular scenario.
b
you can have your script parameter store the value of the script id of the field your user wishes to use
if the field has a value, you add that column to your search
c
I see! Genius.
I wasn’t following that line of thought. That’s helpful. Thank you.
s
@Carl Jenkins Another method I’ve used is to use ‘record.create()’ in the script, and then use the new record object to getFields(), and filter those to the id which starts with ‘custentity_’ — This way, you can add each of these fields automatically to the search columns.. so whenever a custom field is created, it is always included in the search columns. — I typically use this with custom records… Another option I’ve used is to provide a reference to a search where they can add the columns they want, but that can cause problems if they remove dependent columns.
c
@suitedev Thanks, I will look into this. Appreciate the help!