Why is Codeunit not populating table?

vimovimo Member Posts: 14
edited 2016-06-23 in NAV Tips & Tricks
I created a test codeunit and set it up to run from a job queue. It ran fine with no errors, but did not populate the table. I added a message to make sure the date was formatted correctly, and it is. I ran the codeunit without the job queue and it ran with no errors. Here is the code I used:

Documentation()

OnRun()
WITH JobQueueTestLog DO BEGIN
TestDateTime := CURRENTDATETIME;
MESSAGE(FORMAT(TestDateTime));
JobQueueTestLog.INIT;
JobQueueTestLog."Date Time" := TestDateTime ;
END;

My table has two fields, Entry No. (with AutoIncrement set to Yes, data type is Integer), and 'Date Time' (data type set to DateTime). Any ideas on why it won't add anything to the table??? Thanks!

Best Answers

  • foo_barfoo_bar Member Posts: 91
    edited 2016-06-23 Answer ✓
    you need a JobQueueTestLog.INSERT before your END;
    OnRun()
    WITH JobQueueTestLog DO BEGIN
    TestDateTime := CURRENTDATETIME;
    MESSAGE(FORMAT(TestDateTime));
    JobQueueTestLog.INIT;
    JobQueueTestLog."Date Time" := TestDateTime ;
    JobQueueTestLog.INSERT;
    END;
    

Answers

  • foo_barfoo_bar Member Posts: 91
    edited 2016-06-23 Answer ✓
    you need a JobQueueTestLog.INSERT before your END;
    OnRun()
    WITH JobQueueTestLog DO BEGIN
    TestDateTime := CURRENTDATETIME;
    MESSAGE(FORMAT(TestDateTime));
    JobQueueTestLog.INIT;
    JobQueueTestLog."Date Time" := TestDateTime ;
    JobQueueTestLog.INSERT;
    END;
    
Sign In or Register to comment.