.NET event handling Server / Client callback error when opening page 41 / 42

GoonieGoonie Member Posts: 7
Hi.
I really hope I formed the head of my question to make some sense.

I am very new to C/AL . The only things I know is from some specific googleing.

The problem is:

I have my own .NET assembly that selfhosts a simple WCF service, meaning that I can run an URL in a webbrowser e.g
http://localhost:8888/MessageService/ins766/SendMessageAndKey?Message=1002&Key=2

My service listenes for this URI and triggers an event.

This works ok as long as I only try to show a message box. But trying to open an order or quote , I get an error:
'Microsoft Dynamics NAV Application Server attempted to issue a client callback to run page 42 Sales Order. Client callbacks are not supported on Microsoft Dynamics NAV Application Server.'

The C/AL code looks like this:

Variables:

Documentation()

OnRun()

NavEventHandler := NavEventHandler.NavHandler();
IF NavEventHandler.HostOpen THEN BEGIN
MESSAGE('Host is running with URI: %1', NavEventHandler.BaseAddress.AbsoluteUri);
  END 
  ELSE
MESSAGE('Host is not running');

//Test fire from withing the class allows the page to be open:
NavEventHandler.FireInTheHole();

NavEventHandler::ChangedEvent(recordId : Text;recordType : Integer)

MESSAGE('Lookin for: %1 . Type: %2',recordId,recordType);
saleRec."Document Type" := saleRec."Document Type"::Quote;
saleRec."No." := recordId;
saleRec.SETCURRENTKEY(saleRec."No.");
 IF saleRec.FIND('=') THEN BEGIN
MESSAGE('I Found a/an : %1', saleRec."Document Type");
  //orderPage.SETRECORD(saleRec);
  //orderPage.RUN();
  END
 ELSE
MESSAGE('now i Find a/an : %1', saleRec."Document Type");

NavEventHandler::LogEntried(logEntry : Text)

If I run the event from within the class using FireInTheHole method. It works just fine, and it can open a page.

Any thoughts are greatly appreciated :smile:

Best regards
Søren

Answers

  • kaspermoerchkaspermoerch Member Posts: 43
    edited 2016-09-15
    Your error indicates that you have your NavEventHandler running in a Job Queue. If it does so, any interaction that involves UI will cause an error.

    The MESSAGE dialog is handled a little bit different. When called from a Job Queue the message is logged in the Event Log of the server running your Service Tier.

    You can use the keyword GUIALLOWED in your C/AL code to check if you're allowed to interact with the UI.
  • GoonieGoonie Member Posts: 7
    Thanks for your answer Kasper.
    Evaluating GUIALLOWED did show me, that the WCF hosts triggering the event returned false. But triggering it with FireInTheHole method is allowed
    But any Idea why the NavEventHandler runs in a Job Queue ? And how to get it out of there ? :)

    /Søren
  • kaspermoerchkaspermoerch Member Posts: 43
    If it runs on the Job Queue, you would know. You have to set that up through the client.

    It could also indicate that you run your DotNet variables on the server.

    Did you set the RunOnClient property of your NavEventHandler variable to Yes?
  • GoonieGoonie Member Posts: 7
    If I set RunOnClient to yes, then I'm not allowed to set withevents to yes. And I loose my events.

    I have also tried to set class instances on a local variable to listen to the same event, But that yields an serilization error.

    Decorating my .net class with [serilizable] didn't do any difference ...
  • GoonieGoonie Member Posts: 7
    Thanks a lot for your input @kaspermoerch . I have boiled the issue down to a new more manageable question: forum.mibuso.com/discussion/67508/guiallowed-false-for-net-events-e-g-system-io-filesystemwatcher/p1?new=1

    Br
    Søren
Sign In or Register to comment.