Scroll

Global Event: OnDataCombined

The OnDataCombined Event allows the inspection and/or modification of the raw data set after retrieval from the Data Sources and initial combining within Exago. A common use of this event is to modify or blank sensitive data fields in a Report depending on the authorizations available to the user executing the report.

Signature

For custom code the args array is structured as follows:

args[] contains a single DataTable of the combined data in position zero.

For .Net Assemblies the method signature is as follows:

DataTable EventHandlerName(SessionInfo sessionInfo, DataTable combinedData)

Expected Return

The OnDataCombined Event expects a DataTable to be returned. The schema of the DataTable must match that of combinedData.

Notes

In the DataTable, if a Data Object has an Id then that will be used as the column names, otherwise the database name will be used. Data Fields will always use their database names despite any Column Metadata.

Example

The following example checks a Parameter called AllowViewSSN and then censors the columns named SocialSecurityNumber.

System.Data.DataTable dt = (System.Data.DataTable) args[0];
if (sessionInfo.GetConfigParameter(“AllowViewSSN”) == “true” && dt.Columns.Contains("Employees.SocialSecurityNumber"))
{
    //change the value of SSN to blank
    foreach (System.Data.DataRow row in dt.Rows)
    {
        for (int i = 0; i < row.ItemArray.Length; i++)
        {
            row["Employees.SocialSecurityNumber"] = “xxx-xx-xxxx”;
        }
    }
}
return dt;
NOTE. This assumes the column SocialSecurityNumber is saved as a string. If trying to set a date or date time field to blank use System.DBNull.Value.

The following example filters the data based on a calculated age value.

// get field name and age from parameters to compare against
string fieldName = sessionInfo.GetParameter("fieldName").Value;
int age = int.Parse(sessionInfo.GetParameter("age").Value);

// log parameters
sessionInfo.WriteLog("FilterByAge fieldName: " + fieldName);
sessionInfo.WriteLog("FilterByAge age value: " + age.ToString());

// get DataTable view and filter
System.Data.DataTable dt = (System.Data.DataTable)args[0];
System.Data.DataView dv = dt.DefaultView;

foreach(System.Data.DataRowView drv in dv)
{
   if (drv[fieldName] == System.DBNull.Value || (int)((System.DateTime.Today - (System.DateTime)drv[fieldName]).Days / 365) < age)
      drv.Delete();
}

// return filtered DataTable
return dv.ToTable();

 


Hidden Article Information

Article Author
Exago Development
created 2017-02-21 15:50:23 UTC
updated 2017-06-27 14:43:21 UTC

Labels
Server Events, data, event handlers, list of server events, combined, datacombined, retrieved,
Have more questions? Submit a request