Customize Situational Awareness Report

294
7
Jump to solution
03-29-2019 07:30 AM
Highlighted
Occasional Contributor

I'm using Web AppBuilder version 2.8 was wanting to customize the report that gets generated from the situational awareness widget. I know that the map portion of the report can customized based on the print service used, but is there a way to only show the summary table and not the table for the individual records?

Thanks!

1 Solution

Accepted Solutions
Highlighted
Occasional Contributor

I'm sorry about that. These are the lines of code that I commented out.

if (displayFields.length > 0) {
array.forEach(displayFields, function(f){
_names[f.expression] = f.label;
});

for ( var di = 0; di < _r.graphics.length; di++){
_rows_ = [];
var g = _r.graphics[di];
var attributes = g.attributes;
var keys = Object.key(attributes);
if (di === 0){
array.forEach(keys, function(k){
if (_names.hasOwnProperty(k)){
_cols.push(_names[k]);
}
}):
}
array.forEach(keys, function(k){
if (_names.hasOwnProperty(k)){
_rows_.push(analysisUtils.getFieldValue(k, attributes[k], _r.context.specialFields,_r.context.dateFields, _r.context.defaultDateFormat,_r.context.typeIdField, _r.context.types));
}
});
_rows.push(_rows_);
}
dataForReport.push({
title: _r.context.baseLabel,
addPageBreak: false,
type: "table",
data: {
cols: _cols,
rows: _rows
}
});
}

View solution in original post

7 Replies
Highlighted
New Contributor III

Hi Michael, did you find out how to customize situational awareness reports? We have exactly the same problem. So far I've looked into JSON definitions in ArcGIS Online Assistant (https://ago-assistant.esri.com), but couldn't find anything related to the structure of the report.

Perhaps it's worth submitting as an Idea

Reply
0 Kudos
Highlighted
Occasional Contributor

Jan,

I managed to find a workaround. I went into the Widget.js file in the SituationAwareness folder and deleted line 3183 through line 3218. By deleting or commenting out those lines you're left with only the summary results for the layer. I'm not sure if this was the correct way to customize the report, but it worked for me.

Highlighted
New Contributor III

Thanks, this sounds like a good workaround. Can you specify which lines exactly you're commenting? In my case lines 3183-3218 are the following:

//this would not have to be done here once I work out how to avoid the popup blocking thing
var mapIndex;
for (var i = 0; i < data.length; i++) {
var d = data;
if (d.type === 'map') {
mapIndex = i;
d.printTemplate = this._getPrintTemplate();
break;
}
}
if (props.comments && props.comments !== "") {
data.splice(mapIndex + 1, 0, {
type: "html",
data: "<p style='white-space: pre-wrap;'>" + props.comments + "</p>"
});
}

this.reportDijit.maxNoOfCols = props.reportLayout.orientation.Type === "Landscape" ? 12 : 7;
this.reportDijit.print(props.name, data);
this._updateProcessing(this.createReportButton, false, this.reportSrc);
//TODO this is how I'd like to do it but need to understand the window.open/popup blocked issue better
//this._getReportData().then(lang.hitch(this, function (data) {
// this.reportDijit.print(name, data);
// this._updateProcessing(this.createReportButton, false, 'report');
//}));
} else {
this._updateProcessing(this.createReportButton, false, this.reportSrc);
}
}));
}));
}
}
},

_getReportData: function (r) {
var def = new Deferred();

Reply
0 Kudos
Highlighted
Occasional Contributor

I'm sorry about that. These are the lines of code that I commented out.

if (displayFields.length > 0) {
array.forEach(displayFields, function(f){
_names[f.expression] = f.label;
});

for ( var di = 0; di < _r.graphics.length; di++){
_rows_ = [];
var g = _r.graphics[di];
var attributes = g.attributes;
var keys = Object.key(attributes);
if (di === 0){
array.forEach(keys, function(k){
if (_names.hasOwnProperty(k)){
_cols.push(_names[k]);
}
}):
}
array.forEach(keys, function(k){
if (_names.hasOwnProperty(k)){
_rows_.push(analysisUtils.getFieldValue(k, attributes[k], _r.context.specialFields,_r.context.dateFields, _r.context.defaultDateFormat,_r.context.typeIdField, _r.context.types));
}
});
_rows.push(_rows_);
}
dataForReport.push({
title: _r.context.baseLabel,
addPageBreak: false,
type: "table",
data: {
cols: _cols,
rows: _rows
}
});
}

View solution in original post

Highlighted
New Contributor III

Thanks, that worked!

Still, would be nice to just have a checkbox in the UI for that... Or even being able to set this individually for each layer in the Situational Awareness widget...

Highlighted
New Contributor

In the Configure Situation Awareness, I am experiencing an issue printing the report (from the Incident tab) when "Configured pop-up fields" are selected in the Output options. With that option selected, the report is not generated. Change back to the default "All fields" option, the report is generated. Any ideas?

Reply
0 Kudos
Highlighted
New Contributor III

I recently noticed the same thing, still not knowing what might be the reason for this to happen.

Reply
0 Kudos