The primary method for developers to interact with Licentra is licentraLib.isFeatureEnabled(featureId). This method queries the Licentra server (via the configured connection) to determine if a given feature is currently enabled for the NetSuite account or user context.
The unique identifier for the feature as configured in the Licentra platform
Return Object Structure
This method returns an object with the following properties:
Property
Type
Description
enabled
boolean
A boolean value indicating whether the specified feature is currently active and licensed. true if the feature can be used, false otherwise.
message
string
A descriptive message providing details about the feature's status. This can indicate why a feature is disabled (e.g., "License expired", "Feature not subscribed", "Trial period ended") or confirm it's enabled.
Basic Usage
Here's a simple example of how to check if a feature is enabled:
Code
const featureStatus = licentraLib.isFeatureEnabled('YOUR_FEATURE_ID_HERE');if (featureStatus.enabled) { // Execute code related to the enabled feature log.debug({ title: 'Feature Enabled', details: `The feature is enabled: ${featureStatus.message}`, });} else { // Handle the case where the feature is disabled log.audit({ title: 'Feature Disabled', details: `The feature is disabled: ${featureStatus.message}`, }); // You might throw an error, redirect the user, or hide functionality}
Advanced Usage Examples
User Event Script Integration
Code
/** * @param {UserEventContext.beforeLoad} context */const beforeLoad = (context) => { const featureId = 'OPEN_FDA'; try { const featureStatus = licentraLib.isFeatureEnabled(featureId); if (!featureStatus.enabled) { // Hide UI elements or show warning message log.audit('Feature Disabled', featureStatus.message); // Optionally show a user-friendly message if (context.form) { context.form.addField({ id: 'custpage_feature_disabled', type: 'inlinehtml', label: 'Feature Unavailable' }).setDefaultValue(`<div style="color: red;">${featureStatus.message}</div>`); } return; } // Feature is enabled, proceed with normal functionality log.debug('Feature Enabled', featureStatus.message); // Add feature-specific UI elements if (context.form) { context.form.addButton({ id: 'custpage_fda_button', label: 'FDA Lookup', functionName: 'performFDALookup' }); } } catch (error) { log.error('Licentra API Error', error.message); // Handle API errors gracefully }};
Client Script Integration
Code
/** * @param {ClientScriptContext.pageInit} context */const pageInit = (context) => { const featureId = 'ADVANCED_REPORTING'; try { const featureStatus = licentraLib.isFeatureEnabled(featureId); if (!featureStatus.enabled) { // Disable buttons or hide sections const advancedButton = document.getElementById('custpage_advanced_report_btn'); if (advancedButton) { advancedButton.style.display = 'none'; } // Show notification to user alert(`Advanced reporting is not available: ${featureStatus.message}`); } } catch (error) { console.error('Error checking feature status:', error); }};
Always Check Status: Call isFeatureEnabled() before executing feature-specific code
Handle Errors: Wrap API calls in try-catch blocks
User Feedback: Provide clear feedback to users when features are disabled
Graceful Degradation: Design your application to work without disabled features
Logging: Log feature status checks for debugging and audit purposes
Caching: Consider caching results for performance in frequently called scripts
Integration Points
By integrating licentraLib.isFeatureEnabled() calls at critical points in your scripts, you can dynamically control the availability and behavior of your custom NetSuite solutions based on real-time license and subscription data from Licentra.