I’m trying to generate a BAQ report via function call. I’ve followed the trace and seem to be getting hung up on the last method call (Ice.RPT.BAQReportSvc.TransformAndSubmit). I’ve used the “Ice.BAQReport.GetNewBAQReportParam” method to return a tableset. I’ve then used C# to convert the tableset to a dataset to serve as the input param for the TransformAndSubmit method. I’ve verified that my dataset matches exactly to the payload from the trace for this method. When I attempt to make the function call through the API, I continue to get an Invalid Dataset error.
What’s frustrating is that if I copy the dataset output from the API response and use it as an input parameter for the TransformAndSubmit method via Swagger API, I get a status 200 and my report generates without issue. This seems to indicate to me that the ds is complete and adequate?
I’ve tried a number of different strategies, including serializing the ds to json and passing that in as a parameter, initializing the ds as a new object in the C# widget (even though it’s already defined in my function signature), and passing in the tableset as an object parameter, nothing seems to work. Below is my code, @klincecum I’ve seen some similar threads where you’ve offered some things to try. Anything you can think of that might get me over this last hurdle?
try
{
using (DataSet dataSet = new DataSet("ds"))
{
// Explicitly define the type of the tables to process
var tablesToProcess = new List<Tuple<dynamic, string>>()
{
new Tuple<dynamic, string>(baqRptTS.BAQReportParam, "BAQReportParam"),
new Tuple<dynamic, string>(baqRptTS.ReportStyle, "ReportStyle"),
//new Tuple<dynamic, string>(baqRptTS.ExtensionTables, "extensionTables")
};
//Try adding a blank table for ExtensionsTable to match trace
dataSet.Tables.Add(new DataTable("extensionTables"));
foreach (var tableInfo in tablesToProcess)
{
var table = tableInfo.Item1;
var tableName = tableInfo.Item2;
if (table != null)
{
using (DataTable dataTable = new DataTable(tableName))
{
// Step 1: Add columns to the new DataTable
foreach (var column in table.Columns)
{
Type columnType = column.DataType;
// Check if the column type is nullable
if (columnType.IsGenericType && columnType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
// If nullable, use the underlying type and allow nulls
columnType = Nullable.GetUnderlyingType(columnType);
dataTable.Columns.Add(column.ColumnName, columnType).AllowDBNull = true;
}
else
{
dataTable.Columns.Add(column.ColumnName, columnType);
}
}
// Step 2: Copy each row from the source table to the new DataTable
foreach (var sourceRow in table)
{
DataRow newRow = dataTable.NewRow();
// Copy each column's value
foreach (DataColumn column in dataTable.Columns)
{
object value = sourceRow[column.ColumnName];
newRow[column.ColumnName] = value ?? DBNull.Value;
}
dataTable.Rows.Add(newRow);
}
//Testing to add "SSRSRender" column to Report Style table
bool checkForColumn1 = dataTable.Columns.Contains("SSRSRenderFormat");
if (checkForColumn1 == false)
{
dataTable.Columns.Add("SSRSRenderFormat", typeof(string));
foreach (DataRow row in dataTable.Rows)
{
// Set the value for each row in the "SSRSRenderFormat" column
row["SSRSRenderFormat"] = "PDF";
}
}
// Step 3: Add the new DataTable to the DataSet
dataSet.Tables.Add(dataTable);
}
}
}
//ds = new DataSet();
ds = dataSet;
//Try calling transform and submit method from here
CallService<Ice.Contracts.BAQReportSvcContract>(svc =>
{
svc.TransformAndSubmit(ds, "PRINT", 0, 0, "Ice.UIRpt.TEDMtlTag" );
});
}
}
catch (Exception ex)
{
exceptionMsg = "An unexpected error occurred: " + ex.Message + ex.StackTrace;
}