Post Item Journal Line through NAS

HollandPolandHollandPoland Member Posts: 62
Hello everyone!
My customer has to post item journal lines periodically. I create a report that it reads some lines and it creates records in to Item Journal Line table. I'd like to post these records but the job queue returns me an error that I cannot invoke dialogs.
Are there codeunits that I can invoke without dialog that they post Item Journal Line?
Thank you for your replies.

Comments

  • nromainnromain Member Posts: 57
    The NAS does not managed GUI. So you cannot invoke dialogs during your process.

    There is a function in navision to test the GUI. (GUIALLOWED)

    So to run your process with nas you have to put GUIALLOWED before all dialogs.

    Example :

    IF GUIALLOWED THEN
    Message('blablabla...');
  • HollandPolandHollandPoland Member Posts: 62
    nromain wrote:
    The NAS does not managed GUI. So you cannot invoke dialogs during your process.

    There is a function in navision to test the GUI. (GUIALLOWED)

    So to run your process with nas you have to put GUIALLOWED before all dialogs.

    Example :

    IF GUIALLOWED THEN
    Message('blablabla...');

    Ok, I try it. Message and Error dialogs are need to be tested by GUIALLOWED function?
  • nromainnromain Member Posts: 57
    Yes but it depends if you want your error to block the NAS process...
  • HollandPolandHollandPoland Member Posts: 62
    Thak you, I resolve it whith this code before every dialog's function call (OPEN, UPDATE, CLOSE) and before every CONFIRM functon:
    IF GUIALLOWED THEN
      Window.OPEN('something');
    ....
    ....
    
  • afarrafarr Member Posts: 287
    I am trying to run the “Adjust Cost - Item Entries” and “Post Inventory Cost to G/L” reports through NAS (since the client found that Automatic Cost Adjustment was slowing down Navision too much).

    I modified the code wherever a dialog is being opened, closed or updated, and I also set it up to write the time of completion in a table, so that I would know that the reports ran successfully.

    When I run the modified reports manually, they work without any problem.

    But when run through NAS, they hit the following error (reported in the Job Queue Log Entry):
    Another user has modified the record for Post Value Entry to G/L Value Entry No. '43134' after you retrieved it from the database.
    Re-enter the changes in the updated window or start the activity again.


    I thought that the dialog might be doing an implicit Commit, so I tried adding a Commit after each (commented out) dialog open / update / close, to see if this makes a difference.
    But I’m still getting the same error when it runs through NAS.

    Do you know what I could do?
    Alastair Farrugia
  • danlindstromdanlindstrom Member Posts: 130
    Is it the NAV-user that runns report? :-k
    Sound like a possible permissionerror :(
    Regards
    Dan Lindström
    NCSD Navision 2.00 since 1999 (Navision Certified Solution Developer)
    MBSP Developer for Microsoft Dynamics NAV 2009
  • afarrafarr Member Posts: 287
    I restarted the NAS service and tested again - this time it ran without error.
    I then commented out the COMMITs and tested again, and again it ran without error.

    Note - I had made one other change besides commenting out the commits.
    In the Post Inventory Cost to G/L report, I had commented out the following lines:
    IF TempCapValueEntry.FIND('-') THEN
      Window.OPEN(Text99000000);
    

    but of course I should only have commented out the Window.OPEN (and put a ; instead).

    So it was that bugfix, and the service restart that solved the problem. No need for any commits.

    I'll check again next week, after the users have posted several transactions, but I'm pretty sure that the problem is solved now.

    P.S. My NAS service runs as Administrator, Administrator is a Windows login with the SUPER role in Navision, and the error message doesn't mention any permissions, so it wasn't a permission problem.
    Alastair Farrugia
  • alexx_2010alexx_2010 Member Posts: 1
    I think The NAS does not managed GUI.
  • afarrafarr Member Posts: 287
    No NAS can't run forms or dialogs, that's why I needed to comment out the Window.OPEN.
    My problem was that I commented out another line too.

    In general, we shouldn't even comment out the code, but put an IF condition as follows:
    IF TempCapValueEntry.FIND('-') THEN
      IF GUIALLOWED THEN
        Window.OPEN(Text99000000);
    

    However, I had made a copy of Report 1002, which
    (a) called report 795 and
    (b) was only going to be called by NAS
    So in this particular case it was OK to replace the Windows.OPEN with just a semicolon.
    Alastair Farrugia
  • afarrafarr Member Posts: 287
    A short follow-up: besides the 2 reports (Adjust Cost - Item Entries, and Post Invt. Cost to G/L) there are also dialog boxes in codeunit 5895 (Inventory Adjustment) so we need to check for GUIALLOWED there too.
    Alastair Farrugia
Sign In or Register to comment.