I am working in 10.2.700.40 and I trying to create an API of sorts to connect with a third party software via direct link. Once we get into SaaS, this will be MUCH easier. However, for the itme being, I need this working. Below are the steps I took to get to where I am . Bascially, I’ve set up an Function to handle the report generation and a Post-Processing BPM on ExecuteByID to bridge the data, but the BAQ result remains blank.
Fucntion: Used the Assembly Erp.Contracts.Rpt.QuotForm.dll and the Quote services.
Named it GetQuotePDF
string uniqueStamp = Guid.NewGuid().ToString();
// Calls the Quote Report Service
this.CallService<Erp.Contracts.QuotFormSvcContract>(svcQuote => {
var tsQuote = svcQuote.GetNewParameters();
tsQuote.QuoteFormParam[0].QuoteNum = quotenum; // Input parameter
tsQuote.QuoteFormParam[0].ReportStyleNum = [YourStyleNum];
tsQuote.QuoteFormParam[0].TaskNote = uniqueStamp;
tsQuote.QuoteFormParam[0].AutoAction = "SSRSGenerate";
tsQuote.QuoteFormParam[0].AgentID = "SystemTaskAgent";
svcQuote.RunDirect(tsQuote);
});
// Polling loop to wait for Task Agent
int attempts = 0;
bool found = false;
var reportRecord = (dynamic)null;
while (attempts < 15 && !found)
{
System.Threading.Thread.Sleep(1000);
reportRecord = (from srl in this.Db.SysRptLst
join st in this.Db.SysTask on srl.SysTaskNum equals st.SysTaskNum
where st.TaskNote == uniqueStamp
select srl).FirstOrDefault();
if (reportRecord != null && reportRecord.RptData != null)
{
found = true;
}
attempts++;
}
if (found)
{
pdfBase64 = Convert.ToBase64String(reportRecord.RptData); // Output parameter
}
else
{
throw new Exception("Timeout: PDF not found in SysRptLst after 15 seconds.");
}
BAQ had the table Ice.SysCompany with only company in the field. Hoping to ensure a response. Calc Field: PdfBase64 (Type: nvarchar, Format: x(max), Editor: ‘’).
BPM is a post processing on Ice.BO.DynamicQuery.ExecuteByID.
// Debug message to confirm activation
this.PublishInfoMessage("BPM Active. QueryID: [" + queryID + "]", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
if (!queryID.Equals("[YourBAQID]", StringComparison.OrdinalIgnoreCase))
{
return;
}
string quoteNumStr = "0";
if (executionParams != null)
{
foreach (var param in executionParams.ExecutionParameter)
{
if (param.ParameterID.Equals("quoteNum", StringComparison.OrdinalIgnoreCase))
{
quoteNumStr = param.ParameterValue;
break;
}
}
}
// Clean up commas from UI auto-formatting
int quoteNum = 0;
string cleanQuoteNumStr = (quoteNumStr ?? "0").Replace(",", "");
int.TryParse(cleanQuoteNumStr, out quoteNum);
string pdfBase = "";
var efxResult = this.InvokeFunction("[YourLibraryName]", "GetQuotePDF", Tuple.Create(quoteNum));
if (efxResult != null)
{
var resultTuple = efxResult as Tuple<string>;
if (resultTuple != null) { pdfBase = resultTuple.Item1 ?? ""; }
}
if (result != null && result.Tables.Count > 0)
{
foreach (System.Data.DataRow row in result.Tables[0].Rows)
{
if (!string.IsNullOrEmpty(pdfBase))
{
row["Calculated_PdfBase64"] = pdfBase;
}
}
}
Issue: Even though the debug message fires, the PdfBase64 column is empty.