Hi - does anyone know how to add an option to an c...
# suitescript
s
Hi - does anyone know how to add an option to an custom list using a script?
m
this is only possible via suitelet and only for lists that you add on the form while constructing the suitelet itself
๐Ÿ™ 1
b
๐Ÿ‘† Well, unless youโ€™re okay with using undocumented APIs
b
load the
customlist
record and add values to the
customvalue
sublist
you can also treat it as a custom record type and simple create a new record for it
s
@burkybang I'm intrigued... Can you elaborate more on that please or provide any links to the undocumented APIs?
@battk Lemme try loading the customlist
b
Sure, give me a moment
s
can't wait ๐Ÿ˜
@battk that doesn't work because it's not a supported record.
b
use ss2
s
trying...
b
or do it serverside
b
It's a work in progress. I add more as I find them, so feel free to watch the repo. https://github.com/burkybang/NetSuite-UI-Types
๐Ÿ‘Ž 1
s
@battk it worked!! how did you find out about this? AND THANK YOU SO MUCH!!!!
thanks @burkybang - I'm reading through it now
b
I was thinking you wanted to add a custom option to a dropdown based on what @Milcho Dimkov was saying.
s
I wish - that's easy lol
b
Yeah it's easy if you are creating the field via a Suitelet or user event but not if it's a standard field or custom field added via a custom form.
b
a lot of the customizations are scriptable, though not documented as such
s
This did the trick for an existing customlist
battk - you got more?
b
you can create custom fields if you want
for example, the id of a custom item field is
itemcustomfield
s
I have been looking into that as well but how would you create a freeform text field?
b
more specific than that
b
@Shubi Here's an example of what I was talking about.
Copy code
var fieldId = 'account';
var dropdown = getDropdown(document.querySelector('#' + fieldId + '_fs'));
dropdown.addOption('Hello @Shubi!', '100');
s
what would the id of a tran body field be?
yeah that'd do the trick as well. That's actually easier than loading the record and wasting governance. Thanks for that burkybang!
appreciate the help guys!
let's see what NetSuite support has to say about my case lol - I bet they'll give me an enhancement hah
b
It really depends on what you want to do. If you want to only show the new option(s) one time or dynamically, then use my approach, but if you want to add more options to the custom list, then use @battk's.
s
yeah - I think I can use both approaches in my case
b
basic list of supported record types can be found by running in a browser console
Copy code
nsapiInitRecords();
console.log(nsRecordTypes)
find the id you want in the list and see if you can create it
not all work in client script
with serverside script being more lenient
s
Thanks - I try to avoid client scripts as much as I can.
Thanks for teaching me something new today
My words can't express how thankful I am
I have wanted to create a folder via script too. I'm gonna try that next