is it possible to default a value when selecting a...
# ask-stanley-ai
f
is it possible to default a value when selecting an email template category for a specific role?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that it is not directly possible to default a value when selecting an email template category for a specific role in NetSuite. However, there are some workarounds that have been suggested: 1. One user mentioned a solution involving a user event before load on the message record to inject some client-side code into an inline HTML field that would set the field to 'All'. This is a rather hacky solution and might not be suitable for all use cases. 2. Another user suggested customizing the Transaction > Email popup window to set a default email template. This involves appending the template ID to the standard URL. This seems to be a more straightforward solution, but it might not work in all scenarios. 3. A third user suggested using a workflow to restrict users from creating public email templates and defaulting to private templates. However, this approach seems to have resulted in some issues, and the user eventually resorted to creating a user event script to set the 'isprivate' field to true on email templates. Here is the user event script that was shared:
Copy code
javascript
/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
define(['N/record', 'N/log'], function(record, log) {
    
    function beforeLoad(context) {
        if (context.type !== context.UserEventType.CREATE) {
            return;
        }

        try {
            var newRecord = context.newRecord;
            if (newRecord.type === 'emailtemplate') {
                newRecord.setValue({
                    fieldId: 'isprivate',
                    value: true
                });
            }
        } catch (e) {
            log.error({
                title: 'Error setting isPrivate on Email Template',
                details: e.toString()
            });
        }
    }

    return {
        beforeLoad: beforeLoad
    };
});
****** 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.838248
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806481481
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.803492248
Please provide your feedback on this answer.