# 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.

In version 2018.1 this event was extended to provide access to the active execution object, as well as the ability to modify report execution schema via the SessionInfo object. After modifying the execution schema, the method Report.ReprocessAfterAlteration() must be called in order to process the changes.

Signature (pre-v2018.1)

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)

Signature (v2018.1+)

For custom code the args array is structured as follows:

args[] contains a single DataTable of the combined data in position zero and the ActiveLocalExecution object in position one.

For .Net Assemblies the method signature is as follows:

DataTable EventHandlerName(SessionInfo sessionInfo, DataTable combinedData, ActiveLocalExecution execution)

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();