Fetching Company Preferences Date Format

To fetch company preferences, including the date format, we use the config.load() method. The config module in SuiteScript enables developers to interact with the configuration data stored in the system. Specifically, to retrieve company preferences, you would load the configuration for COMPANY_PREFERENCES, which is one of the predefined configuration types.

function getCompanyDateFormat() {

  try {

    let companyPreferences = config.load({

      type: config.Type.COMPANY_PREFERENCES

    });

     

    let dateFormat = companyPreferences.getValue({

      fieldId: ‘DATEFORMAT’

    });

     

    log.debug(‘Company Date Format:’, dateFormat);

    return dateFormat;

  } catch (e) {

    log.error(‘Error retrieving date format’, e);

    return null;

  }

}

Leave a comment

Your email address will not be published. Required fields are marked *