when click on button, transaction from will save a...
# ask-stanley-ai
i
when click on button, transaction from will save and get back to edit mode using suite script
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that you want to save a record and then redirect to the view mode of the record when a button is clicked. Here's a possible solution: 1. Create a button in a User Event script in edit mode. This button will trigger a client-side script when clicked. 2. In the client-side script, you can show a dialog for confirmation. If the user confirms, you can proceed with the next steps. 3. SuiteScript does not offer a direct method to save the current record. However, you can manipulate the DOM to achieve this. 4. After saving the record, you can use the
afterSubmit
event to redirect to the view mode of the record. Here's a sample code snippet that you can use as a reference:
Copy code
javascript
function afterSubmit(context) {
    if (context.type === context.UserEventType.CREATE || context.type === context.UserEventType.EDIT) {
        var record = context.newRecord;
        var recordId = record.id;
        var recordType = record.type;
        var url = urlModule.resolveRecord({
            recordType: recordType,
            recordId: recordId,
            isEditMode: false
        });
        redirect.toUrl(url);
    }
}
Please note that this is a general approach and you might need to adjust it according to your specific requirements. Also, remember that manipulating the DOM is not a recommended practice as it can lead to unpredictable results and might not be compatible with future NetSuite updates. ****** 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.855500579
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847049534
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841929078
Please provide your feedback on this answer.