0

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

Community
  • 1
  • 1
meriam bambia
  • 11
  • 1
  • 4

1 Answers1

0

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.

Mak Sim
  • 2,148
  • 19
  • 30
  • Thanks for your reply. All the .net variables property RunOnClient are set to true. How could I check if I have the needed libraries on the nav server, please? – meriam bambia Jun 17 '19 at 13:41
  • How do you know you have those libraries on the client? – Mak Sim Jun 17 '19 at 19:52
  • You can use linked objects instead btw https://learn.microsoft.com/en-us/dynamics-nav/using-linked-objects – Mak Sim Jun 17 '19 at 19:55