0
votes

I have an Error while running a Codeunit through job queue, even though this code unit works fine when I run it manually. Error: "Microsoft Dynamics NAV Server attempted to issue a client callback to create a .NET object: System.Data.SqlClient.SqlConnection (Report 50126 NewOrdersCust). Client recalls are not supported for Microsoft Dynamics NAV Server."

This code unit runs a report and saves it as a pdf file in a folder.

CodeUnit:

OnRun(VAR Rec : Record "Job Queue Entry")
 IF GUIALLOWED THEN BEGIN
 programm:='\\MB\Navision\ReportsMB\PDFSoftware\cpdf.exe';
//Merged PDF1
Output := '\\MB\Navision\ReportsMB\Customers.pdf';
directory:= '\\MB\Navision\ReportsMB\2019\Customers';
Filename1:='\\MB\Navision\ReportsMB\2019\Kunden_Vertrieb\CustomersOrders.pdf';
Report1.SAVEASPDF(Filename1);
END;

The report is actually based on an SQL query:

Report:

MyReport - OnPreDataItem()
Servername:='*.*.*.*';
DBName:='DB';
GetSQLConnection(SQLConnection,Servername,DBName);

QueryinText:='select * from [SickDays] K  Order by Year DESC, Code ASC, Monat DESC ';

SQLCommand:=SQLCommand.SqlCommand(QueryinText,SQLConnection);
SQLConnection.Open();
Queryread :=SQLCommand.ExecuteReader;

MyReport - OnAfterGetRecord()
IF (Queryread.Read()) THEN
       BEGIN
       LoopCount+=1;
       Year:= Queryread.Item(0);
       KrankDays:=Queryread.Item(5);
       END
ELSE
    BEGIN
       SQLConnection.Close();
       CurrReport.BREAK;
    END;

SETRANGE(Number,1,  LoopCount);

MyReport - OnPostDataItem()

GetSQLConnection(VAR SQLConnection : DotNet "System.Data.SqlClient.SqlConnection";Servername : Code[20];DBName : Code[20])
SQLConnection :=
  SQLConnection.SqlConnection(
    STRSUBSTNO(
      'Data Source=%1;Initial Catalog=%2;Integrated Security=SSPI',
      Servername,DBName));

This report contains the following .net variables

1

1 Answers

0
votes

On the .net variables you have probably set property RunOnClient to True. You can’t do that if you want to run this report on server. Set this property to false and make sure you have needed libraries on the nav server.