NAV 2018 - Task scheudler strange behavor

massive_cava@hotmail.itmassive_cava@hotmail.it Member Posts: 16
edited 2024-07-30 in NAV Three Tier
Hello NAV and BC experts,

i want to share with you a strange behavior i'm expiriencing within a process which is using task scheduler to execut background task. Appearently, the task created by the process are all exevuted except some with a very specific property. Here the case:i have created a table "Post Process Buffer" wich contain an Entry No. as a key and field named "Record Id" of type RecordId wich contain the id of the record to process.
"Post Process Buffer" is used in a page list with a button. Code behind the button is following:

TASKSCHEDULER.CREATETASK(CODEUNIT::"APT PostProcess Data Execution",
CODEUNIT::"APT Post Exception Mgt.",
TRUE,
COMPANYNAME,
CURRENTDATETIME,
Rec.RECORDID);

The purpose of this is to run in background a codeunit which will differentiate the execution based on Rec."Record Id" table. The value in the "Record Id" referes to different custom tables (specifically 4). All i want to do is pass to my codeunit only the "Post Process Buffer" record. When i hit the button this happen:
- if Rec."Record Id" referes to record in table (let's say) A, b or C, it runs normally and the task is executed
- if Rec."Record Id" referes to record in table D it IS NOT executed.

The very strange thing is that also putting simply an erro for testing purtpose immediatly CODEUNIT::"APT PostProcess Data Execution", the error is logged only for only table A B and C (error is logged by CODEUNIT::"APT Post Exception Mgt." and put in a text field of "Post Process Buffer" ). It's look like the task never run for a specific table, also if the table is specified in a field ofteh record i pass as parameter.

In this image there is an example with the task not executed:
ffc7bbq79n8d.png

Does anyone have experinced the same behavior? Any hint or suggestion?

Thanks a lot

Omar
OC

Best Answer

  • massive_cava@hotmail.itmassive_cava@hotmail.it Member Posts: 16
    Answer ✓
    Hi all,

    i think i've figured out what was the problem and it seems to be the excessive number of field in the primary key of my table (to stick with the notation i used in my original post, the table D). Here you can see the Scheudled task table with two records:
    m0hcnbvvaile.png

    Both record are pointing to a record of my "Post process Buffer" table but:
    - the first one has a record Id pointing to a single-primary key field. This record belong to a new table i created for this test, and the purpose of this table is to store a GUID that will be put in my D table to have a 1 on 1 relation (this GUID is also the primary key)
    - the second one point to my D table (wich has 7 field in primary key).

    The execution of first record in taskl scheduler is simple: get the GUID, make a search in table D and process the record as normal. Of these two record only the first one is executed correctly by the task scheduler.
    After this test then i tried to completely change the primary key in my table D, using just a GUID field, after that the task scheudle rwork as expected.

    Has anyone ever saw somenthing like this? I've neever read anything on MS learn abouth primary key limitation for task scheduler, but maybe i've miss somnthing.
    Do you thing a question to microsoft can be useful?

    Best regards.

    Omar


    OC

Answers

  • massive_cava@hotmail.itmassive_cava@hotmail.it Member Posts: 16
    Answer ✓
    Hi all,

    i think i've figured out what was the problem and it seems to be the excessive number of field in the primary key of my table (to stick with the notation i used in my original post, the table D). Here you can see the Scheudled task table with two records:
    m0hcnbvvaile.png

    Both record are pointing to a record of my "Post process Buffer" table but:
    - the first one has a record Id pointing to a single-primary key field. This record belong to a new table i created for this test, and the purpose of this table is to store a GUID that will be put in my D table to have a 1 on 1 relation (this GUID is also the primary key)
    - the second one point to my D table (wich has 7 field in primary key).

    The execution of first record in taskl scheduler is simple: get the GUID, make a search in table D and process the record as normal. Of these two record only the first one is executed correctly by the task scheduler.
    After this test then i tried to completely change the primary key in my table D, using just a GUID field, after that the task scheudle rwork as expected.

    Has anyone ever saw somenthing like this? I've neever read anything on MS learn abouth primary key limitation for task scheduler, but maybe i've miss somnthing.
    Do you thing a question to microsoft can be useful?

    Best regards.

    Omar


    OC
  • vaprogvaprog Member Posts: 1,139
    The record stored in Scheduled Task is stored there using a field of type RecordID. This is a binary datatype. It is highly unlikely that this limits the primary key in any way. If it did, this was a bug in the platform (NAV of BC)

    The problem more likely is in how you process "Post Process Buffer"."Record Id" in your handler codeunit.

    Please also check, if this issue has anything to do at all with the fact the record is processed using a Scheduled Task. Just try calling you handler codeunit with the "Post Process Buffer" directly from code.

    Your test with just returning an error from CODEUNIT::"APT PostProcess Data Execution" seens to suggest there is an issue with the RecordID indeed, but I do not have sufficient information to judge for sure. If it really is, you should contact Microsoft about it.
Sign In or Register to comment.