AL icon indicating copy to clipboard operation
AL copied to clipboard

Not able to get proper result as required

Open RagRawat opened this issue 8 years ago • 3 comments

Describe the bug

I want to delete one Field which I created through VS Code. means That field will be blank which I created in "Vendor Ledger Entry" when I delete that "Gen. Journal Line" table's one Line. In "Vendor Ledger Entry" : One Field : AlreadyDone : Boolean: Created In "Gen. Journal Line" : on Delete: Trigger : Want to write code to change values in "Vendor Ledger Entry" Issue is Using Setrange, fields Like "Applies-to ID" similar to "Applies-to ID" with "Gen. Journal Line". but one function "ClearCustVendApplnEntry;" clears that field "Applies-to ID" to blank. How Can I do the same with VS Code.

To Reproduce Steps and/or AL code to reproduce the behavior:

  1. Go to '[email protected]:RagRawat/Bank-Upload.git'

Expected behavior Need to clear my new field with that.

Versions: September 2018 (version 1.28) - 1.28.2 Business Central Fall 2018 update (CURRENT - 2018/08/27)

  • Business Central: 13.0.24623.0

RagRawat avatar Oct 18 '18 09:10 RagRawat

Find required event and write your code..

AmolSalvi avatar Oct 18 '18 10:10 AmolSalvi

Yes, you will replace direct modifications with event triggers. Create a function in a custom codeunit like this:

   [EventSubscriber(ObjectType::Table, DATABASE::"Gen. Journal Line", 'OnAfterDeleteEvent', '', true, true)]
    local procedure ItemOnAfterDelete(var Rec: Record "Gen. Journal Line"; RunTrigger: Boolean);`
      BEGIN
        IF Rec.ISTEMPORARY THEN
          EXIT;
        <perform operations>
      END;

Whenever a Gen. Journal Line gets deleted, whether or not the delete trigger is called, this function will be called (even from temp recs).

Frantic42 avatar Oct 22 '18 07:10 Frantic42

Yes, you will replace direct modifications with event triggers. Create a function in a custom codeunit like this:

   [EventSubscriber(ObjectType::Table, DATABASE::"Gen. Journal Line", 'OnAfterDeleteEvent', '', true, true)]
    local procedure ItemOnAfterDelete(var Rec: Record "Gen. Journal Line"; RunTrigger: Boolean);`
      BEGIN
        IF Rec.ISTEMPORARY THEN
          EXIT;
        <perform operations>
      END;

Whenever a Gen. Journal Line gets deleted, whether or not the delete trigger is called, this function will be called (even from temp recs).

Frantic42 avatar Oct 22 '18 07:10 Frantic42