I'm trying to create a custom button which links m...
# ask-stanley-ai
a
I'm trying to create a custom button which links me to a different page on NetSuite. How would I achieve this?
c
AI generated answer (using internal Slack threads):
To create a custom button in NetSuite that links to a different page, you can use SuiteScript. Here's a general approach: 1. Create a client script that will be triggered when the button is clicked. In this script, you can use the
N/redirect
module to redirect to the desired page. 2. Add the custom button to your record. You can do this by navigating to the record type in the customization section, then go to the forms subtab, and then to the buttons subtab. Here you can add a new button and link it to the client script you created. Here's a sample code snippet for the client script:
Copy code
javascript
/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 */
define(['N/redirect'], function(redirect) {
    function redirectToPage() {
        redirect.toSuitelet({
            scriptId: 'customscript_my_sscript', 
            deploymentId: 'customdeploy_my_sscript'
        });
    }

    return {
        pageInit: function(context) {
            context.currentRecord.addButton({
                id: 'custpage_my_button',
                label: 'My Button',
                functionName: 'redirectToPage'
            });
        }
    };
});
In this example,
customscript_my_sscript
and
customdeploy_my_sscript
are the script ID and deployment ID of the Suitelet you want to redirect to.
custpage_my_button
is the ID of the button, and 'My Button' is the label that will be displayed on the button. Remember to replace the scriptId, deploymentId, id, and label with your actual values. ****** 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.860648215
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851541579
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845894039
Please provide your feedback on this answer.