How to add button on a case that creates a quote f...
# ask-stanley-ai
s
How to add button on a case that creates a quote from that case using the case information?
c
AI generated answer (using internal Slack threads):
To add a button on a case that creates a quote from that case using the case information, you can use SuiteScript. Here's a general approach: 1. Create a client script that will be used to define the function that will be executed when the button is clicked. This function will gather the necessary information from the case record and then redirect to a Suitelet.
Copy code
javascript
define(['N/currentRecord', 'N/url'], function(currentRecord, url) {
    function createQuoteFromCase() {
        var caseRecord = currentRecord.get();
        var caseId = caseRecord.id;
        var suiteletUrl = url.resolveScript({
            scriptId: 'customscript_my_suitelet',
            deploymentId: 'customdeploy_my_suitelet',
            params: {
                caseId: caseId
            }
        });
        window.location = suiteletUrl;
    }
    return {
        createQuoteFromCase: createQuoteFromCase
    };
});
2. Create a Suitelet that will be used to create the quote. This Suitelet will take the caseId from the URL parameters, load the case record, create a new quote record, and populate it with the necessary information from the case.
Copy code
javascript
define(['N/record', 'N/search'], function(record, search) {
    function onRequest(context) {
        var caseId = context.request.parameters.caseId;
        var caseRecord = record.load({type: 'SUPPORTCASE', id: caseId});
        var quoteRecord = record.create({type: 'ESTIMATE'});
        // Populate the quote record with information from the case record
        // ...
        quoteRecord.save();
        context.response.write('Quote created successfully');
    }
    return {
        onRequest: onRequest
    };
});
3. Add the button to the case form. You can do this by going to the form customization page, selecting your case form, and adding a button in the 'Buttons' subtab. Set the function to be executed when the button is clicked to be the function defined in your client script. Please replace 'customscript_my_suitelet' and 'customdeploy_my_suitelet' with your actual Suitelet scriptId and deploymentId. ****** 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.838608801
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832580626
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823003411
Please provide your feedback on this answer.