Options

Set Job Task No. with extension

AitorEGAitorEG Member Posts: 342
Hi everyone,

I'm finding a problem finding the event where I can set the "job Task No." before the insert of the registry.

In a job card, when I'm trying to create a Job Task, I want to create it without setting the Job Task No, which I want to be filled when inserting, adding for example, the date. Which event can I sue fro this purpose? I'm trying to use the events from the "Job Task" table, but I can't find the correct way.... Is possible to develop this with extensions?

Thank you very much

Comments

  • Options
    RobyRRobyR Member Posts: 39
    Hi @AitorEG , where you want to insert that value? In the Job Ledger Entry?
    Try checking the posting codeunits, it should be possible quite sure
  • Options
    AitorEGAitorEG Member Posts: 342
    RobyR wrote: »
    Hi @AitorEG , where you want to insert that value? In the Job Ledger Entry?
    Try checking the posting codeunits, it should be possible quite sure

    Hi @RobyR
    No, the idea is to inserte the value into the Job Task (table 1001)
  • Options
    RobyRRobyR Member Posts: 39
    Ok, than you want to set it when the user set the Job Task date, right? What about the OnAfterValidate event on the table, for the Date field?
  • Options
    AitorEGAitorEG Member Posts: 342
    Well, the issue is the next.

    In the job card, I try to create a new line. I don't fill the "JobTaskNo", and when NAV tries to insert the new registry, I get the error, telling that I must fill the JobTaskNo. So, I think that the best event should be "OnbeforeInsertEvent", and i coded like this:
    [EventSubscriber(ObjectType::Table, Database::"Job Task", 'OnBeforeInsertEvent', '', true, true)]
        local procedure setJobTaskNo(VAR Rec: Record "Job Task")
        begin
            if Rec."Job Task No." = '' then begin
                Rec."Job Task No." := '123456';
                Rec.Modify();
            end;
        end;
    

    But I still having the same issue, probably because i am using "Rec", and this rec doesn't exist, because the insert is not done yet...
  • Options
    RobyRRobyR Member Posts: 39
    Try removing the Rec.Modify, if for your situation the event is correct, this should solve your issue
  • Options
    AitorEGAitorEG Member Posts: 342
    RobyR wrote: »
    Try removing the Rec.Modify, if for your situation the event is correct, this should solve your issue

    Thnks for your answer, but still having the same issue. The error notification appears even before the break I added for debugging:
    t2916d37axbt.png

  • Options
    RobyRRobyR Member Posts: 39
    Ok, the issue could be caused by "manually permitted" setted to false on Job Task no. Series.
    Try to set it to false and check if this solve the issue
  • Options
    AitorEGAitorEG Member Posts: 342
    Same problem again...

    I've simplified the code like this, just to show a message in the event:
    [EventSubscriber(ObjectType::Table, Database::"Job Task", 'OnBeforeInsertEvent', '', true, true)]
        local procedure setJobTaskNo(VAR Rec: Record "Job Task")
        begin
            Message('aitor');
    
        end;
    

    But the error notification appears before my message, so, the validation is made before the "OnBeforeInsertEvent"...
Sign In or Register to comment.