NAS posting codeunit 90, returns false

MauddibMauddib Member Posts: 269
I will make up a scenario here to simpify the issue im having...

I have a report which calls a function in a codeunit. The report is scheduled to run with the NAS once a day.

In the codeunit the function posts purchase orders by doing some processing then saying:

IF LUnitPurchPost.RUN(LRecPOHead) THEN BEGIN
//Some happy code here
END ELSE BEGIN
//Some unhappy code here
END;

(LUnitPurchPost is codeunit 90. Whenever I run the report manually all is good. However whenever the NAS runs it it always goes into the unhappy code. I can't see why. I've even logged in as the same user the nas uses to log in and posts POs manually to ensure they don't have errors there (permissions etc).

Comments

  • ara3nara3n Member Posts: 9,256
    Hello Mauddib
    Run the codeunit without the if statement and check the event log and you'll see error. Most likely reason is window.open('. You need to write if GUIALLOWED then window.open,

    window.update and window.close in CU 90.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • MauddibMauddib Member Posts: 269
    Its not a window.open or update. I checked for this in codeunit 90. In fact I turned on code coverage and posted one of the purchase orders and checked ALL the code, even code not in codeunit 90, to see if any dialouges were called anywhere that shouldnt be. But there is nothing.

    Its seemingly inexplicable. Whenever I run my process manually it works a charm, but when run via the nas user it sometimes doesnt. Whenever it fails I can see the PO it failed on but if i go and manually post that po it works fine.
  • ara3nara3n Member Posts: 9,256
    remove the error catching process. So that it errors out in NAS and then check the event log.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • WaldoWaldo Member Posts: 3,412
    Tried to run this with the latest NAV runtime version?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • andy76andy76 Member Posts: 616
    Also I have a similar problem . Have you solved it? How?

    Thank you
  • garakgarak Member Posts: 3,263
    check if you have somewhere a dialog (to disable dialog when NAS runs the codeunit use GUIALLOWED before the Dialog) and check also the permissions of the NAS user. If you think all is fine, start the codeunit from NAS without the if codeunit.run. Use Codeunit.run() (without the if XXXX then). So the erroe will be written in the eventlog and you can see the reason. Also you can debug the NAS viewtopic.php?f=23&t=25967
    Don't forgett, when you start the debugger on NAS the NAs runs with your windowslogin. so set before your windowslogin the same permissions like the originen NAS user or Start the NAS debug with the NAS WindowsLogin (Logon on Windows with the NAS account)

    Regards
    Do you make it right, it works too!
Sign In or Register to comment.