datadaddy
(Scott Janisch)
April 17, 2025, 3:49pm
1
Have a function to submit an AR Invoice form to System agent.
I am getting an exception “Invalid AgentID”
I looked in System Agent Maintenance and the ID is set to “SystemAgentID”
I’ve tried that, also setting it to WorkstationID, also leaving it blank
The trace in Kinetic developer tools has it as blank
This is my code: (function)
this.CallService<Erp.Contracts.ARInvFormSvcContract>(arInvFrm =>
{
var arInvFrmTs = arInvFrm.GetNewParameters();
arInvFrmTs.ARInvFormParam[0].InvoiceNum = iInvoiceNum;
// arInvFrmTs.ARInvFormParam[0].AgentID = "SystemTaskAgent";
arInvFrmTs.ARInvFormParam[0].AgentID = this.Session.WorkstationID;
arInvFrmTs.ARInvFormParam[0].AutoAction = "SSRSPreview";
arInvFrmTs.ARInvFormParam[0].CalledFrom = "Erp.UI.ARInvoiceEntry";
arInvFrmTs.ARInvFormParam[0].ReportStyleNum = iReportStyleNum;
arInvFrmTs.ARInvFormParam[0].SSRSRenderFormat = "PDF";
arInvFrmTs.ARInvFormParam[0].SSRSEnableRouting = ! iPreviewOnly;
// arInvFrmTs.ARInvFormParam[0].TaskNote = taskNote;
arInvFrmTs.ARInvFormParam[0].WorkstationID = this.Session.WorkstationID;
// arInvFrm.RunDirect(arInvFrmTs);
arInvFrm.SubmitToAgent(arInvFrmTs, "SystemAgent", 0, 0, "Erp.UIRpt.ARInvForm");
});
1 Like
klincecum
(Kevin Lincecum)
April 17, 2025, 4:32pm
2
This BO? Erp.Contracts.ARInvFormSvcContract
datadaddy
(Scott Janisch)
April 17, 2025, 4:33pm
3
yep, sorry, just noticed 1st line was not displayed
klincecum
(Kevin Lincecum)
April 17, 2025, 4:34pm
4
My code from function that does the same:
string uniqueStringToIdentifyReport = Guid.NewGuid().ToString();
CallService<Erp.Contracts.ARInvFormSvcContract>(ari =>
{
var ariTS = ari.GetNewParameters();
var ariParams = ariTS.ARInvFormParam.FirstOrDefault();
ariParams.InvoiceNum = InvoiceNum;
ariParams.AutoAction = SSRSAction.ToUpper();
ariParams.WorkstationID = "web_" + Session.UserID;
ariParams.ReportStyleNum = ReportStyle;
ariParams.TaskNote = uniqueStringToIdentifyReport;
ari.RunDirect(ariTS);
});
var reportDataBytes = (from sysReport in Db.SysRptLst
join sysTask in Db.SysTask on
sysReport.SysTaskNum equals sysTask.SysTaskNum
where sysTask.TaskNote == uniqueStringToIdentifyReport
select sysReport.RptData).FirstOrDefault();
if(reportDataBytes != null)
{
ReportB64 = System.Convert.ToBase64String(reportDataBytes);
}
klincecum
(Kevin Lincecum)
April 17, 2025, 4:36pm
5
Let me try the submittoagent real quick.
klincecum
(Kevin Lincecum)
April 17, 2025, 4:38pm
6
Looks like I have that precoded, un momento.
1 Like
klincecum
(Kevin Lincecum)
April 17, 2025, 4:42pm
7
oh ffs, report not in pilot lol, one more sec
datadaddy
(Scott Janisch)
April 17, 2025, 4:50pm
8
It did work for me with the RunDirect which kind of makes sense because it doesn’t need an agent
but I don’t really want to read the data back, I just wanna pop open the preview or in another case send an email (we are using APR break/routing rules)
klincecum
(Kevin Lincecum)
April 17, 2025, 4:51pm
9
My ssrs is acting funny, here test this code for submittoagent
string uniqueStringToIdentifyReport = Guid.NewGuid().ToString();
CallService<Erp.Contracts.ARInvFormSvcContract>(ari =>
{
var ariTS = ari.GetNewParameters();
var ariParams = ariTS.ARInvFormParam.FirstOrDefault();
ariParams.InvoiceNum = InvoiceNum;
ariParams.AutoAction = SSRSAction.ToUpper();
ariParams.WorkstationID = "web_" + Session.UserID;
ariParams.ReportStyleNum = ReportStyle;
ariParams.TaskNote = uniqueStringToIdentifyReport;
ari.SubmitToAgent(ariTS, "SystemTaskAgent", 0, 0, "Erp.UIRpt.ARInvForm");
datadaddy
(Scott Janisch)
April 17, 2025, 4:54pm
10
Hmmm, you’re not even setting AgentID, which I’ve tried but still errors.
Maybe it’s how you have WorkStationID wired up, mine is different, I’ll give that a try
klincecum
(Kevin Lincecum)
April 17, 2025, 4:58pm
11
datadaddy:
WorkStationID
Is NOT a workstation id.
You used to be able to use
$"{Session.ClientComputerName} {Session.ClientTerminalID}"
but that broke and I’m not sure it has been fixed.
klincecum
(Kevin Lincecum)
April 17, 2025, 5:05pm
12
$"{Session.ClientComputerName} {Session.ClientTerminalID}"
and $"web_{Session.UserID}"
both seems to work now
I’d use the latter.
datadaddy
(Scott Janisch)
April 17, 2025, 5:18pm
13
klincecum:
$“web_{Session.UserID}”
That works for you ? (not for me)
I printed my AgentID and it looks legit “web_ScottJ”
wanna send me your last code set ?
I’ll try it verbatim
thanks
klincecum
(Kevin Lincecum)
April 17, 2025, 7:04pm
14
What I posted last is what I use. What did the system agent say?
datadaddy
(Scott Janisch)
April 17, 2025, 7:18pm
15
and you successfully set AgentID using $“web_{Session.UserID}” ?
I switched my code to be setup same as yours and set the AgentID to above, still get the error
It never gets to the system agent, the SubmitToAgent call throws an exception in the function and it dies there.
The odd thing is if I look at the trace (network/payload) from using the standard print screen that field is empty in the json for the dataset.
If I use that same payload in a REST testing tool it works,
Yet, if I set ALL the parameters in the ARInvFormParam’s row to the same values of the payload in the function I get the error - makes no sense.
I opened a ticket with Epicare but I’m sure the response will be, “we don’t help with customizations”
thanks for your efforts tho
klincecum
(Kevin Lincecum)
April 17, 2025, 7:24pm
16
I don’t set the AgentID
at all. That is already set from GetNewParameters()
;
The WorkstationID
is what I set to $"web_{Session.UserID}"
.
datadaddy
(Scott Janisch)
April 17, 2025, 7:35pm
17
Yeah, that was one of the first things I tried (not setting AgentID), still got the error…this is what I currently have just to be clear
this.CallService<Erp.Contracts.ARInvFormSvcContract>(arInvFrm =>
{
var arInvFrmTs = arInvFrm.GetNewParameters();
var ariParams = arInvFrmTs.ARInvFormParam.FirstOrDefault();
ariParams.InvoiceNum = iInvoiceNum;
ariParams.AutoAction = "SSRSPreview";
ariParams.CalledFrom = "Erp.UI.ARInvoiceEntry";
ariParams.ReportStyleNum = iReportStyleNum;
ariParams.SSRSRenderFormat = "PDF";
ariParams.SSRSEnableRouting = ! iPreviewOnly;
ariParams.TaskNote = Guid.NewGuid().ToString();
ariParams.WorkstationID = "web_" + Session.UserID;
// arInvFrm.RunDirect(arInvFrmTs);
arInvFrm.SubmitToAgent(arInvFrmTs, "SystemAgent", 0, 0, "Erp.UIRpt.ARInvForm");
});
klincecum
(Kevin Lincecum)
April 17, 2025, 7:48pm
18
datadaddy:
"SystemAgent"
uhmmmm lol
try this
this.CallService<Erp.Contracts.ARInvFormSvcContract>(arInvFrm =>
{
var arInvFrmTs = arInvFrm.GetNewParameters();
var ariParams = arInvFrmTs.ARInvFormParam.FirstOrDefault();
ariParams.InvoiceNum = iInvoiceNum;
ariParams.AutoAction = "SSRSPREVIEW";
ariParams.ReportStyleNum = iReportStyleNum;
ariParams.WorkstationID = "web_" + Session.UserID;
arInvFrm.SubmitToAgent(arInvFrmTs, "SystemTaskAgent", 0, 0, "Erp.UIRpt.ARInvForm");
});
1 Like
datadaddy
(Scott Janisch)
April 17, 2025, 8:00pm
19
well, that gave me a different result at least…now a got a correlation Id error with no info on the detail screen except “Business Layer Exception”, but maybe it’s a step forward.
I’ll have to turn on server trace and see if I can find the error
klincecum
(Kevin Lincecum)
April 17, 2025, 8:02pm
20
Add a string output to your function
wrap it in this
try
{
//code here
}
catch (Exception ex)
{
yourNewOutput = ex.Message;
}
Then you can see what happened in the response from wherever you’re testing.