Can we inject jQuery in a suitelet within the same...
# suitescript
a
Can we inject jQuery in a suitelet within the same script file?
b
you can add it as a custom module in your client script
i expect it to fail serverside in the suitelet code
a
But it's just one suitelet, how can I add it? Should I create a client script and then set client script in suitelet?
b
not sure what you expect to do with jQuery serverside
its designed for use client side in the browser
a
Hide some elements
b
there are no elements in a suitelet in the server code
you would do that client side, in the client script
a
Form fields
So how can I hide form fields?
Where is the client script?
I have only one suitelet
b
a serverWidget.Field does not implement the Element interface
a
So I can't hide that?
I have to somehow load this suitelet in another client script?
b
its just an object that the netsuite server uses to generate a html document
the html document is returned from the server to the browser, which parses the html and then generates all the elements needed to display the page
keep in mind that elements that you manipulate with jQuery run in the browser
the code that a suitelet runs is run on netsuite's server
a
So we can't hide it
?
b
you can add client script to the html document that netsuite generates by using Form.clientScriptModulePath
a
And there is no other option
b
for your particular use case, you can use Field.updateDisplayType to control the visibility of the element that the suitelet generates
a
Another issue with suitelet is when you load it in an iframe it doesn't show select options
Is that normal
b
suitelet select type fields have undocumented behavior around select fields
a
@battk many thanks Is there a solution at the end to fix this? This select field is showing from a suitelet GET request in an iframe
b
what does your code look like
a
Suitelet code?
b
might as well give the ifrrame too
a
Suitelet is checking request first if(isGetRequest){ typeFld= form.addField(id, type: select, label) options.forEach(option => typeFld.addSelectOption(text, value, isSelected: false) }
Iframe is just an iframe with the suitelet src
b
you would need to give more of the suitelet code
in particular where the options are coming from
a
const options = ["big", "medium", "small" ]
b
that looks like it should work, but you really need to learn how to copy and paste code into here
that said, add logging for incoming requests
if you dont see extra GETS when the select field is selected, then something is wrong
a
That's all
But it will just show the select field without any options
b
dunno what to tell you
i can tell you that suitelets work normally in iframes, including select fields
for example, i can make an iframe on a subtab that looks like
normally i could verify it with your actual code , but i dont have it so you are basically left with I can make suitelets in iframes show select options
a
I will share actual code Another thing to mention that I can see options in the page source but I can't open the select field and see other options
b
im not sure what im supposed to get from this
at best, it looks like i have a fragment of a script, which is not something i can deploy to a test account