Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Sales Line Trigger Not firing on field "Completely Shipped"

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

tableextension 50166 "FOR Sales Line Tbl Ext" extends "Sales Line"
{

    fields
    {
        modify("Qty. Invoiced (Base)")
        {
            trigger OnAfterValidate()
            var
            begin
                HandleTrigger(triggerEnum::modify);
            end;
        }
        modify("Completely Shipped")
        {
            trigger OnAfterValidate()
            var
            begin
                HandleTrigger(triggerEnum::modify);
            end;
        }
    }


    trigger OnAfterInsert()
    var
        payload: JsonObject;
        payload_text: Text;
        data: JsonObject;

    begin
        HandleTrigger(triggerEnum::insert);
    end;

    trigger OnAfterModify()
    var
        payload: JsonObject;
        payload_text: Text;
        data: JsonObject;

    begin
        HandleTrigger(triggerEnum::modify);
    end;


    trigger OnBeforeDelete()
    var
        payload: JsonObject;
        payload_text: Text;
        data: JsonObject;
    begin
        HandleTrigger(triggerEnum::delete);
    end;

    trigger OnAfterDelete()
    begin
        simSH(triggerEnum::modify);
    end;

    local procedure HandleTrigger(triggerName: Enum TriggerEnum)
    var
        payload: JsonObject;
        payload_text: Text;
        data: JsonObject;
        sodata: JsonObject;
        Item: Record "Item";
        itemdata: JsonObject;
        so: Record "Sales Header";
        linePage: JsonObject;
        linesCU: Codeunit "Sales Orders";
    begin
        // check if the record exists
        // if not sl.get(rec."Document Type", rec."Document No.", rec."Line No.") then exit; // working solution
        //check if the record is temporary
        // if rec.IsTemporary() then exit;
        // add rec info to data field
        Message('Sending Sales Line Trigger');
        data := triggerData();
        // line trigger to update sales line
        buildPayload.HandleTrigger(env.IsProduction(), Rec.CurrentCompany(), Rec.TableName(), data, triggerName);
        // sales order trigger to update sales order
        so.get(rec."Document Type", rec."Document No.");// faster than findset() -> for repeating and loooping.
        sodata := buildPayload.SalesHeaderData(so);
        sodata.Add('from', 'sales line sim');
        buildPayload.HandleTrigger(env.IsProduction(), Rec.CurrentCompany(), so.TableName(), sodata, triggerEnum::modify);
        // item trigger to update page ats
        if not Item.Get(Rec."No.") then exit;
        itemdata := buildPayload.ItemData(Item);
        itemdata := buildPayload.ItemData(Item);
        buildPayload.HandleTrigger(env.IsProduction(), Rec.CurrentCompany(), Item.TableName(), itemdata, triggerName);


    end;
    
    
}

I am trying to send an http request to an external application. I am really interested in knowing when a sales line is fully shipped. I originally did not have any fields but because the bottom triggers did not work on "Completely shipped" i added it manually.

I checked the field and it does not seem to be a flow field and it is just a boolean. Anybody know what might cause this to not fire my procedural when a sales line is completely shipped?

  • Suggested answer
    Andy Sather Profile Picture
    Andy Sather on at
    RE: Sales Line Trigger Not firing on field "Completely Shipped"

    Hello Rodrigo- We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding, I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    I will open this up to the community in case they have something to add.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans