How to create field groups in company custom prefe...
# ask-stanley-ai
p
How to create field groups in company custom preferences
c
AI generated answer (using internal Slack threads):
To create field groups in company custom preferences, you can follow these steps: 1. Create a script record. This can be of most types, such as User Event, Map/Reduce, Client, etc. 2. In the script record, add Parameters. These parameters will serve as your custom fields. 3. Set the Script Parameter Preference to
Company
. This will make the parameters accessible from the Company General Preferences. Here is a sample code snippet that demonstrates how to set a value for a custom company parameter:
Copy code
javascript
export function execute() {
    setPreference();
}

function setPreference() {
    let companyPreferences = config.load({
        type: config.Type.COMPANY_PREFERENCES
    })
    companyPreferences.setValue({
        fieldId: 'custscript_value',
        value: '13'
    })
    companyPreferences.save()
    companyPreferences = config.load({
        type: config.Type.COMPANY_PREFERENCES
    })
    let value = companyPreferences.getValue({fieldId: 'custscript_value'})
    log.debug({
        title: 'Custom Value',
        details: value
    });
}
In this example,
custscript_value
is a custom company parameter that has been added to a script. The
setPreference
function sets a value for this parameter, saves the company preferences, reloads them, and then logs the new value of the parameter. Remember, once a parameter is set to
Company
preference, it can be accessed from any script using
N/config
to load the company preferences. ****** 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.835018814
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83235997
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830913424
Please provide your feedback on this answer.