Suitescript to add selection for the custom button
# ask-stanley-ai
v
Suitescript to add selection for the custom button
c
AI generated answer (using internal Slack threads):
To add a custom button to a saved search, you can create a Suitelet that displays the search and the button. You can load an existing saved search in your Suitelet. Here is a basic example of how you can do this:
Copy code
javascript
var search = nlapiLoadSearch(null, 'customsearch_your_search_id');
var newButton = form.addButton('custpage_button', 'Create a Bill', 'buttonFunction()');
In the above code,
nlapiLoadSearch
is used to load the saved search and
form.addButton
is used to add a new button to the form. The
buttonFunction()
is the function that will be called when the button is clicked. To change the color of the button to blue like the default NetSuite buttons, you can use DOM manipulation in your client script that handles the button click under the
pageInit
function. Here is an example:
Copy code
javascript
function pageInit(type){
    if(type == 'view'){
        document.getElementById("custpage_button").style.background='#000000';
    }
}
In the above code,
document.getElementById("custpage_button").style.background='#000000';
is used to change the background color of the button. You can replace
#000000
with the color code of your choice. Please note that manipulating the DOM directly is not recommended as it can lead to unpredictable results and may not be compatible with all browsers or future versions of NetSuite. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.833153486
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83079952
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829470456
Please provide your feedback on this answer.