In project status report, I want to show risks from the source table instead of risk_baseline table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
I have created a custom report template to extract project status report in PDF from reports tab of the Project Workspace. Here, I have extended the script include "StatusReportDynamicTemplateSchemaSNC" function "
risk_baseline: {
sourecTable: "risk",
baselineTable: "",
encodedQuery: "active=true^taskISNOTEMPTY",
baselineTableEncodedQuery: "",
orderBy: "number",
label: gs.getMessage('Risk')
},Then I have extended the script include "StatusReportDynamicTemplateDataProvider" function "
var StatusReportDynamicTemplateDataProvider = Class.create();
StatusReportDynamicTemplateDataProvider.prototype = Object.extendsObject(sn_pw.StatusReportDynamicTemplateDataProviderSNC, {
_fetchDataFromBaselines: function(entity, fieldNames, reportRecord) {
// === RISKS: Force live table instead of baseline ===
if (entity === 'risk_baseline') {
return this._fetchLiveRisks(fieldNames, reportRecord);
}
// All other entities (issues, decisions, milestones, etc.) → keep OOB behavior
return this._super(entity, fieldNames, reportRecord);
},
_fetchDataFromSourceTables: function(entity, fieldNames, reportRecord) {
// === RISKS: Also force live table when no baseline exists ===
if (entity === 'risk_baseline') {
return this._fetchLiveRisks(fieldNames, reportRecord);
}
return this._super(entity, fieldNames, reportRecord);
},
_fetchLiveRisks: function(fieldNames, reportRecord) {
var projectId = reportRecord.getValue('project');
if (!projectId) {
return [];
}
var queryObj = {
task: projectId,
active: true
};
var testGr = new GlideRecord('risk');
if (testGr.isValidField('show_on_status_report')) {
queryObj.show_on_status_report = true;
}
var schema = new sn_pw.StatusReportDynamicTemplateSchema();
var config = schema.dynamicTemplateSchemaTableConfig();
var riskConfig = config['risk_baseline']; // key stays 'risk_baseline'
// Force table to 'risk' and use correct query
return this._fetchRecords('risk', queryObj, fieldNames, riskConfig);
},
_fetchRecords: function(tableName, queryObj, fieldNames, entitySchemaConfig) {
var encodedQuery;
// If baselineTable is empty or doesn't match → use live table query
if (!entitySchemaConfig.baselineTable || tableName !== entitySchemaConfig.baselineTable) {
encodedQuery = entitySchemaConfig.encodedQuery || '';
} else {
encodedQuery = entitySchemaConfig.baselineTableEncodedQuery || '';
}
var orderBy = entitySchemaConfig.orderBy || 'sys_created_on';
var gr = this._queryGlideRecord(tableName, queryObj, orderBy, encodedQuery);
return this._createRecordObjects(gr, fieldNames, tableName);
},
type: 'StatusReportDynamicTemplateDataProvider'
});
- Labels:
-
Project Portfolio Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @UtsabGiri
You’re not missing a query instead this is framework behaviour .
In Project Workspace status reports, the entity key (risk_baseline) drives the data path, not the sourceTable defined in the schema. As long as the key is risk_baseline, the engine assumes a baseline exists and keeps resolving data through baseline logic, even if you point it to the risk table.
That’s why overriding _fetchDataFromBaselines() alone doesn’t work.
Try this method once
Explicitly tell the framework that this entity has no baseline:
If you found this useful, please mark it as Helpful and Accepted. This action benefits both the community and me.
Regards,
- Ankit
LinkedIn: https://www.linkedin.com/in/sharmaankith/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The issue is that the engine still treats **`risk_baseline` as a baseline entity**, so baseline logic overrides your fetch.
You can’t reliably force it to use the `risk` table.
**Fix:** define a new entity (e.g. `risk_live`) pointing to the `risk` table and fetch data for that entity instead.
