Posting Sales Orders using NAS

ALopez27ALopez27 Member Posts: 42
NAV Gurus,

I've looked at entire forum but cannot find an answer to my specific problem, which is the following:

I've created a codeunit that will post ship sales orders using the Navision Application Server, I have modified CU80 (Sales-Post) to supress all instances of any dialog windows from opening or updating (was getting error 'You cannot use C/AL variables of type DIALOG when running the Application Server for Microsoft Dynamics NAV Classic.'), after the modifiction, I am now getting error 'You cannot use C/AL variables of type FORM when running the Application Server for Microsoft Dynamics NAV Classic.'.

I've looked at the entire codeunit 80 and all local functions and I cannot find any variables of type FORM, furthermore, I've remmed out all instances of all dialog windows that I can find, when I run this same routine on the foreground on my workstation, it posts the sales order successfully with absolutely no windows or forms popping up, can anyone give me a hint as to why I'm getting this error when running on the NAS?

Comments

  • bbrownbbrown Member Posts: 3,268
    Are you working with lot or serial tracked items? The error is coming from the tracking logic on form 6510
    There are no bugs - only undocumented features.
  • ALopez27ALopez27 Member Posts: 42
    Yes, I'm working with item tracking items, but why does a form or dialog box not pop-up when I run this on a regular client? I ran the exact same routine and nothing (no errors or windows/messages) poped-up on my screen and posted correctly.
  • bbrownbbrown Member Posts: 3,268
    The functions for handling item tracking are actaully on a form. Calling these form-based functions works just fine from a normal client. But try it from NAS (which can't run forms) and guess what happens.
    There are no bugs - only undocumented features.
  • ALopez27ALopez27 Member Posts: 42
    Thanks for the info, I guess there is no way then to run the posting routine (CU80) using the NAS for Lot tracked items....
  • bbrownbbrown Member Posts: 3,268
    Well at least not without some customization work.
    There are no bugs - only undocumented features.
  • BeliasBelias Member Posts: 2,998
    Actually, i posted a sales document with item tracking from nas...i just have had to add "if guiallowed then" to any instance of "window" variable in codeunit 80, and also "dialog" in codeunit 22 (just to be sure).
    :-k actually, i am not using the VERY STANDARD tracking module, but a modifed one...i'm wondering where did we do different... :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BernardJBernardJ Member Posts: 57
    Run the process manually with client monitor enabled and search for any Form in parameter no 14 (Source Object)
  • rjsfrjsf Member Posts: 17
    I am on the same situation, I was getting the 'You cannot use C/AL variables of type DIALOG when running the Application Server for Microsoft Dynamics NAV Classic' error message when calling codeunit 80 running in NAS. I'm trying to modify codeunit 80 and add GUIALLOWED to any MESSAGE functions, but I did not find a single MESSAGE function in it. Instead I found ERROR functions that I know also generate dialog boxes. The thing is the ERROR function not just displays dialogs but also terminates the script. If I simply put the ERROR function in a GUIALLOWED block, then the script will continue when it should not:

    IF GUIALLOWED THEN
    ERROR(Text000);

    So I guess I should simulate the behavior of the ERROR function but not show a dialog box. How do I achieve that?

    IF GUIALLOWED THEN
    MESSAGE(Text000)
    ELSE
    // <what to do here?>
  • pawanppawanp Member Posts: 90
    Not sure if this would work. Did you try with ERROR('')?
  • BeliasBelias Member Posts: 2,998
    you don't have to condition messages and errors...they do not stop the nas (actually, it's very dangerous to ignore the errors!).
    You need to condition the "confirm" instructions and dialog type variables.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • KeeperRUKeeperRU Member Posts: 58
    rjsf wrote:
    I am on the same situation, I was getting the 'You cannot use C/AL variables of type DIALOG when running the Application Server for Microsoft Dynamics NAV Classic' error message when calling codeunit 80 running in NAS. I'm trying to modify codeunit 80 and add GUIALLOWED to any MESSAGE functions, but I did not find a single MESSAGE function in it. Instead I found ERROR functions that I know also generate dialog boxes. The thing is the ERROR function not just displays dialogs but also terminates the script. If I simply put the ERROR function in a GUIALLOWED block, then the script will continue when it should not:

    IF GUIALLOWED THEN
    ERROR(Text000);

    So I guess I should simulate the behavior of the ERROR function but not show a dialog box. How do I achieve that?

    IF GUIALLOWED THEN
    MESSAGE(Text000)
    ELSE
    // <what to do here?>

    Do You want to replace ERROR to MESSAGE? But's that big mistake... you can post broken data.

    IF GUIALLOWED THEN
    ERROR(Text000);
    ELSE
    BEGIN
    SendToLogTable(Text000); //Your function, if you want to write error to some Log file
    EXIT; //it's not right to continue
    END;
  • ppavukppavuk Member Posts: 334
    IF GUIALLOWED THEN
    ERROR(Text000);
    ELSE
    BEGIN
    SendToLogTable(Text000); //Your function, if you want to write error to some Log file
    EXIT; //it's not right to continue
    END;

    Your code will exit and commit. There must be error to roll-back! If you want to log something - do something like
    if not codeunit.run(rec) then begin
     LogError(GETLASTERRORTEXT);
    end;
    
  • BeliasBelias Member Posts: 2,998
    //NO!!! DON'T WRITE THIS CODE!!!
    IF GUIALLOWED THEN
     ERROR(Text000);
    ELSE
    BEGIN
     SendToLogTable(Text000); //Your function, if you want to write error to some Log file
     EXIT; //it's not right to continue
    END;
    //NO!!! DON'T WRITE THIS CODE!!!
    
    do not use the code suggested. It's very dangerous to replace errors with exits! If there are nested function:
    - ERROR aborts the execution of the process and rolls back to the last commit
    - EXIT exits the current function and the execution proceeds!!!!

    if you want to do a "try-catch" like process, you have to wrap your errors in an IF codeunit.run then (search GETLASTERRORTEXT in this forum..you should find useful threads)
    EDIT: ppavuk was faster, but i wrote my post with all my love and i didn't want to waste it :)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • KeeperRUKeeperRU Member Posts: 58
    My mistake, of course I mean what you say.
  • bbrownbbrown Member Posts: 3,268
    We seem to have gotten of issue here. The problem is not the messages. It's because you can't run forms under NAS. Because they are using item tracking and the related functions are on a form (6510). The solution is to move those functions to a codeunit so NAS can use them.
    There are no bugs - only undocumented features.
  • ppavukppavuk Member Posts: 334
    Yep, the item tracking is ugly and incompatible with NAS.

    By to add another 2cents - messages and errors aren't problem for NAS. The dialogs and forms - are.

    As far as I know messages will be just omitted, but errors will be logged to windows application log.
  • vaprogvaprog Member Posts: 1,146
    ppavuk wrote:
    As far as I know messages will be just omitted, but errors will be logged to windows application log.
    Messages are logged to the event log as well. Errors are logged as errors, messages as information.
  • ppavukppavuk Member Posts: 334
    Yep, double-checked, you are right.
  • rjsfrjsf Member Posts: 17
    Guys,

    I figured this is on topic so I'll post here.
    I've gotten rid of all the message issues and am probably facing another one.

    Recently the users are complaining that they get an error message when they are trying to post.
    Something like "The ... cannot be changed because it is locked by another user".
    So trying to isolate the cause I turned off the NAS and the problem went away.

    So I believe my little NAS posting routine is locking the users out from doing their own posting.
    Have any of you dealt with that issue before? Any suggestions?

    Thanks
Sign In or Register to comment.