Options

Report on a JobQueue sais execute is ok but when i check the changes it didnt do anyting

rcseiprcseip Member Posts: 4
edited 2025-07-08 in NAV Three Tier
Hi im new here,
I have 2 environment of nav 2017, one for development (in our servers) and one for production(in Azure).
I develop a report that check records on a table, if they have Status = Awaiting it grab the record, block warehouse entry and insert the rec in it, go back to the table and change status Awaiting to Inserted.

the funny thing here is that i develop this in Dev environment, the report works and i set the job on queue and check that it works fine, all good since here.
(Dev environment is a copy of Pro with a difference of 2-4 months in data no development in job queue)
(User that launch job have "SUPER" same user launch other jobs that works)
(Report dont have any starting parameters or any special permissions, just check a table filtered by Status Field Value)

But when i export the objects to pro environment, the report itself works fine but when I add it to the job queue the logs said it execute fine but when i check the status column of the table the record still "Awaiting" then i check warehouse entry and the report didnt do nothing here.

How can it be posible that it execute ok with dev environment, a copy of pro environment, but when i import to pro it fails.... and the logs said it work.
To fix this temporary i set a page with a PageAction to launch the report, but ill apreciate if i can fix the queue problem and make it to launch automatically.

I have other jobs in the queue that works fine.

Anyone can let me a hand, please :( ?
Thanks for taking your time to read the post.

EDIT: i have the command COMMIT; after the change of the Status Awaiting to Inserted, the code is right, because it works in dev env in the job queue, but maybe the problem is Azure?

Answers

  • joosthegerjoostheger Member Posts: 12
    Can you share some code?
  • rcseiprcseip Member Posts: 4
    edited 2025-07-15
    Simple code for grab a rec(duplicate table structure as Warehouse entry) and insert in Warehouse entry

    Some details of the code
    WhseEntry -> Table "Warehouse Entry" of nav
    AppAlm_WHEntry_Buffer -> Custom table with same structure as Warehouse entry
    TablaIntermedia -> same table as AppAlm_WHEntry_Buffer but with another name

    The comments are in spanish but i translated it for you

    Documentation()
    //En las propiedades del report filtramos por Estado::Pendiente
    // In the report propierties is filtered by Status::Pending
    OnInitReport()

    OnPreReport()

    OnPostReport()

    AppAlm_WHEntry_Buffer - OnPreDataItem()

    AppAlm_WHEntry_Buffer - OnAfterGetRecord()
    // Variables
    WhseEntry_LastID := 0;

    // Obtenemos el ultimo ID de wharehouse entry
    //Las ID of warehouse entry
    WhseEntry.LOCKTABLE(TRUE); //Esperara hasta que se desbloquee la tabla
    WhseEntry.RESET;
    WhseEntry.SETCURRENTKEY("Entry No.");
    WhseEntry.SETASCENDING("Entry No.", FALSE);

    IF WhseEntry.FINDFIRST() THEN BEGIN
    // Si lo obtenemos lo guardamos en una variable
    WhseEntry_LastID := WhseEntry."Entry No." + 1;

    // A continuacion preparamos los campos para la inserccion
    WhseEntry.RESET;
    WhseEntry.INIT;
    WhseEntry."Entry No." := WhseEntry_LastID;
    WhseEntry."Journal Batch Name" := AppAlm_WHEntry_Buffer."Journal Batch Name";
    WhseEntry."Line No." := AppAlm_WHEntry_Buffer."Line No.";
    WhseEntry."Registering Date" := AppAlm_WHEntry_Buffer."Registering Date";
    WhseEntry."Location Code" := AppAlm_WHEntry_Buffer."Location Code";
    WhseEntry."Zone Code" := AppAlm_WHEntry_Buffer."Zone Code";
    WhseEntry."Bin Code" := AppAlm_WHEntry_Buffer."Bin Code";
    WhseEntry.Description := AppAlm_WHEntry_Buffer.Description;
    WhseEntry."Item No." := AppAlm_WHEntry_Buffer."Item No.";
    WhseEntry.Quantity := AppAlm_WHEntry_Buffer.Quantity;
    WhseEntry."Qty. (Base)" := AppAlm_WHEntry_Buffer."Qty. (Base)";
    WhseEntry."Source Type" := AppAlm_WHEntry_Buffer."Source Type";
    WhseEntry."Source Subtype" := AppAlm_WHEntry_Buffer."Source Subtype";
    WhseEntry."Source No." := AppAlm_WHEntry_Buffer."Source No.";
    WhseEntry."Source Line No." := AppAlm_WHEntry_Buffer."Source Line No.";
    WhseEntry."Source Subline No." := AppAlm_WHEntry_Buffer."Source Subline No.";
    WhseEntry."Source Document" := AppAlm_WHEntry_Buffer."Source Document";
    WhseEntry."Source Code" := AppAlm_WHEntry_Buffer."Source Code";
    WhseEntry."Reason Code" := AppAlm_WHEntry_Buffer."Reason Code";
    WhseEntry."No. Series" := AppAlm_WHEntry_Buffer."No. Series";
    WhseEntry."Bin Type Code" := AppAlm_WHEntry_Buffer."Bin Type Code";
    WhseEntry.Cubage := AppAlm_WHEntry_Buffer.Cubage;
    WhseEntry.Weight := AppAlm_WHEntry_Buffer.Weight;
    WhseEntry."Journal Template Name" := AppAlm_WHEntry_Buffer."Journal Template Name";
    WhseEntry."Whse. Document No." := AppAlm_WHEntry_Buffer."Whse. Document No.";
    WhseEntry."Whse. Document Type" := AppAlm_WHEntry_Buffer."Whse. Document Type";
    WhseEntry."Whse. Document Line No." := AppAlm_WHEntry_Buffer."Whse. Document Line No.";
    WhseEntry."Entry Type" := AppAlm_WHEntry_Buffer."Entry Type";
    WhseEntry."Reference Document" := AppAlm_WHEntry_Buffer."Reference Document";
    WhseEntry."Reference No." := AppAlm_WHEntry_Buffer."Reference No.";
    WhseEntry."User ID" := AppAlm_WHEntry_Buffer."User ID";
    WhseEntry."Variant Code" := AppAlm_WHEntry_Buffer."Variant Code";
    WhseEntry."Qty. per Unit of Measure" := AppAlm_WHEntry_Buffer."Qty. per Unit of Measure";
    WhseEntry."Unit of Measure Code" := AppAlm_WHEntry_Buffer."Unit of Measure Code";
    WhseEntry."Serial No." := AppAlm_WHEntry_Buffer."Serial No.";
    WhseEntry."Lot No." := AppAlm_WHEntry_Buffer."Lot No.";
    WhseEntry."Warranty Date" := AppAlm_WHEntry_Buffer."Warranty Date";
    WhseEntry."Expiration Date" := AppAlm_WHEntry_Buffer."Expiration Date";
    WhseEntry."Phys Invt Counting Period Code" := AppAlm_WHEntry_Buffer."Phys Invt Counting Period Code";
    WhseEntry."Phys Invt Counting Period Type" := AppAlm_WHEntry_Buffer."Phys Invt Counting Period Type";
    WhseEntry.Dedicated := AppAlm_WHEntry_Buffer.Dedicated;
    WhseEntry."Descripcion Producto" := AppAlm_WHEntry_Buffer."Descripcion Producto";

    IF WhseEntry.INSERT THEN BEGIN
    // Cuando insertamos el registro, el campo estado cambia a insertado
    // de forma que si hay algun fallo lo podremos localizar por este campo
    // buscando los pendientes.
    // When is inserted we grab the rec of AppAlm_WHEntry_Buffer and change status::Inserted
    TablaIntermedia.RESET;
    TablaIntermedia.SETFILTER(ID_Buffer, FORMAT(AppAlm_WHEntry_Buffer.ID_Buffer));
    TablaIntermedia.SETFILTER(Estado, FORMAT(AppAlm_WHEntry_Buffer.Estado::Pendiente));//Pending
    IF TablaIntermedia.FINDFIRST() THEN BEGIN
    TablaIntermedia.Estado := AppAlm_WHEntry_Buffer.Estado::Insertado;//Inserted
    TablaIntermedia."Entry No." := WhseEntry_LastID;
    TablaIntermedia.MODIFY;
    COMMIT;
    //MESSAGE('Se han procesado las lineas pendientes');
    END;

    END ELSE BEGIN
    // Insert failed
    ERROR('No se ha podido realizar el insert');
    EXIT;
    END;
    END ELSE BEGIN
    // WhseEntry.FINDFIRST() ELSE
    EXIT;
    END;

    AppAlm_WHEntry_Buffer - OnPostDataItem()

    EDIT:
    I was surfing the internet while i saw this post

    https://www.cloudfronts.com/blog/dynamics-nav/what-do-you-do-when-your-nav-2017-job-is-not-triggering-through-job-queue-entries/

    in resume it force the execution of the task by windows task shceduler with a powershell as intermediary, ill try it in dev env, I update the post with the result.
    It will work as an alternative solution.

    UPDATE:
    It works on dev env :)
    Would be quite funny that this didnt work in prod env like the nav scheduler task :D
Sign In or Register to comment.