Skip to main content
Business Central forum
Suggested answer

Changing Report Layout in a Events Subscriber Procedure

editSubscribe (0) ShareShare
ReportReport
Posted on by 85
Hi ,
I have an Event Subscriber that gets called for Drop Shipment function. Inside the event Subscriber I would like to change the layout of the standard Purchase order. The Report :: line is showing me an error. Can someone please take a look at it. The error says "end expected"
[EventSubscriber(ObjectType::Table, Database::"Purchase Line", 'OnValidateVariantCodeOnBeforeDropShipmentError', '', true, true)]
    local procedure dropShipProcedure()
    begin
        Report:: "Standard Purchase - Order" = './layout/DropshipPurchaseOrder.docx';
        Message('This is a drop shipment');
    end;
Regards.
  • Leo99 Profile Picture
    Leo99 85 on at
    RE: Changing Report Layout in a Events Subscriber Procedure

    It won't let me execute during that event.

    The following AL methods are limited during write transactions because one or more tables will be locked:

    Form.RunModal is not allowed in write transactions.

    Codeunit.Run is allowed in write transactions only if the return value is not used. For example, 'OK := Codeunit.Run()' is not allowed.

    Report.RunModal is allowed in write transactions only if 'RequestForm = false'. For example, 'Report.RunModal(...,false)' is allowed.

    XmlPort.RunModal is allowed in write transactions only if 'RequestForm = false'. For example, 'XmlPort.RunModal(...,false)' is allowed.

    Use the commit method to save the changes before this call, or structure the code differently.

    Contact your application developer for further assistance.

    Thanks for the reply

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,714 Super User on at
    RE: Changing Report Layout in a Events Subscriber Procedure

    If what you are trying to do is the execute the report you must use the report.execute or report.print commands.

    Please see this doc:

    docs.microsoft.com/.../reportinstance-execute-method

    The report = method will not be recognized i think.

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Sundar…

Industry experts answer burning questions directly from our amazing Community…

Enabling Copilot Case and Conversation…

Agents can easily recap an ongoing chat, transcribe a voice conversation…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 282,978 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,562 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans