I want Code Snippet for

sraosrao Member Posts: 4
SO , i am extending standard purchase order report and i added three columns 1.SalesorderName 2.SalesorderEmail 3.SalesorderPhoneNo. Now into these columns i want the data to be flowed from "SalesPeople/Purchaser" Base table. In purchase order card page there is an action called dimension which is linked to "Dimension set entry table" and if in the field "Dimension code" value is "sales Rep"(General Ledger Setup table "short cut Dimension 5 code) and if the "Dimenson value code" matches the "Code" field in "Salesperson/Purchaser" table then my columns need to get values from that particular record of "Salesperson/Purchaser"

Answers

  • TallyHoTallyHo Member Posts: 416
    // Report Extension Object
    reportextension 50100 "Ext. Purchase Order Report" extends "Standard Purchase Order Report"
    {
    dataset
    {
    dataitem(PurchaseHeader; "Purchase Header")
    {
    // Adding columns for Sales Order fields
    column(SalesorderName; Text[50])
    {
    DataType = Text;
    }
    column(SalesorderEmail; Text[100])
    {
    DataType = Text;
    }
    column(SalesorderPhoneNo; Text[30])
    {
    DataType = Text;
    }
    }
    }

    // Trigger to populate fields
    trigger OnAfterGetRecord()
    var
    DimSetEntry: Record "Dimension Set Entry";
    SalesPerson: Record "Salesperson/Purchaser";
    GLSetup: Record "General Ledger Setup";
    DimCode: Code[20];
    begin
    // Retrieve Shortcut Dimension 5 Code from General Ledger Setup
    GLSetup.Get();
    DimCode := GLSetup."Shortcut Dimension 5 Code";

    // Check if Dimension Code and Dimension Value Code match
    if DimSetEntry.Get("Dimension Set ID", DimCode) then begin
    if DimSetEntry."Dimension Value Code" <> '' then begin
    // Lookup Salesperson/Purchaser record based on Dimension Value Code
    if SalesPerson.Get(DimSetEntry."Dimension Value Code") then begin
    SalesorderName := SalesPerson.Name;
    SalesorderEmail := SalesPerson."E-Mail";
    SalesorderPhoneNo := SalesPerson.Phone;
    end;
    end;
    end;
    end;
    }
Sign In or Register to comment.