Scot Sunnergren
05/15/2025, 2:59 PMAnthony OConnor
05/15/2025, 3:27 PMAnthony OConnor
05/15/2025, 3:27 PMAnthony OConnor
05/15/2025, 3:28 PMScot Sunnergren
05/15/2025, 3:37 PMAnthony OConnor
05/15/2025, 3:42 PMerictgrubaugh
05/15/2025, 5:29 PMFred Pope
05/15/2025, 5:31 PMscriptExecution/[scriptType]/[scriptId]
)
2. Create utility classes for consistent instrumentation
3. Subscribe monitoring/logging components to these topics
4. Implement dashboards/reports against the captured data
Advantages:
• Captures execution across all script types (scheduled, user event, etc.)
• Provides precise timing information
• Requires minimal code changes to existing scripts
• Separates monitoring from business logic
• Scales better than relying on built-in logging
• Can capture contextual data (record types, IDs, etc.)
Disadvantages:
• Requires changes to all scripts you want to monitor
• Slight performance overhead for each script execution
• Need to manage storage/retention of monitoring data
• Requires establishing governance around topic usage
• Additional complexity compared to native solutions
// Example instrumentation utility
function ScriptMonitor(scriptId, scriptType) {
this.scriptId = scriptId;
this.scriptType = scriptType;
this.startTime = new Date();
this.checkpoints = {};
// Publish start event
N.topic.publish({
topic: `scriptExecution/${scriptType}/${scriptId}/start`,
message: {
scriptId: this.scriptId,
startTime: this.startTime,
context: N.runtime.executionContext
}
});
this.checkpoint = function(name) {
const time = new Date();
this.checkpoints[name] = time;
N.topic.publish({
topic: `scriptExecution/${scriptType}/${scriptId}/checkpoint`,
message: {
scriptId: this.scriptId,
checkpointName: name,
checkpointTime: time,
elapsedSinceStart: time - this.startTime
}
});
};
this.end = function(status) {
const endTime = new Date();
const duration = endTime - this.startTime;
N.topic.publish({
topic: `scriptExecution/${scriptType}/${scriptId}/end`,
message: {
scriptId: this.scriptId,
startTime: this.startTime,
endTime: endTime,
duration: duration,
status: status,
checkpoints: this.checkpoints
}
});
};
}
Scot Sunnergren
05/15/2025, 5:33 PMerictgrubaugh
05/15/2025, 5:36 PMFred Pope
05/15/2025, 5:52 PMAnthony OConnor
05/15/2025, 5:56 PMit appears that I would need to edit every one of our scriptsits worse than that... you can only do this for your custom scripts, any locked scripts from suiteapps/bundles you can't edit so you're SOL
Scot Sunnergren
05/16/2025, 1:19 PMScot Sunnergren
05/16/2025, 1:20 PMit appears that I would need to edit every one of our scriptsits worse than that... you can only do this for your custom scripts, any locked scripts from suiteapps/bundles you can't edit so you're SOL" I am mostly concerned about our own scripts as they are constantly under development/redevelopment. Those that have come in bundles are mostly static and have not caused issues that I am aware of.