Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Unanswered

PO Report Attachment Automatic; Putting SO No. in Planning Worksheet

(1) ShareShare
ReportReport
Posted on by 2

Hi Everyone,

I am working on the AL coding to fulfil my company's demand but I'm facing a couple of problem here.


1.
I have created an Automate Flow when users press the /Send Approval Request/ button in the Purchase Order page.

So we can find the button /Attach as PDF/ in Print/Send, but I want it automatic.
What I'm trying to do is to automatically generate a PO report to the document attachment when a user press the /Send Approval Request/ button before my flow gets start.

Therefore, my flow can merge the PO PDF file with my Power BI reports.
Simply saying, I want the /Attach as PDF/ automatically done when I press /Send Approval Request/.

I have changed some part of the code from this website (https://yzhums.com/20657/) to suit my situation as below:

 

pageextension 50108 PurchaseOrderExt extends /Purchase Order/
{
    actions
    {
        modify(SendApprovalRequest)
        {
            trigger OnAfterAction()
            var
                ReportSelections: Record /Report Selections/;
                Usage: Enum /Report Selection Usage/;
                PurchaseHeader: Record /Purchase Header/;
            begin
                PurchaseHeader := Rec;
                PurchaseHeader.SetRecFilter();
                ReportSelections.SaveAsDocumentAttachment(
                            Usage::/P.Order/.AsInteger(), PurchaseHeader, PurchaseHeader./No./, PurchaseHeader./buy-from Vendor No./, false);
            end;
        }
    }



However, when I press the /Send Approval Request/ button,
it shows this error and I couldn't solve this:

The changes to the Purchase Header record cannot be saved because some information on the page is not up-to-date. Close the page, reopen it, and try again.

Identification fields and values:

Document Type='Order',No.='106010'

 

Now I haven't connect the Automation flow with the approval workflow yet, so now in the sandbox has only a standard approval template workflow.

 

Update:

I changed the trigger OnBeforeAction() to OnAfterAction(). It's working fine for now. Haven't tested it might affect my flow or not since the sandbox doens't have flow yet.

I'll try to make a test flow and see if this is ok to use and update here.

I'm just posting this one for sharing.

but the next question we really can't solve it.


2.
Another issue we have here.
Our planner wants the planning worksheet in dynamics shows the sales order No. if the demand is coming from a Sales Order because the Planning Worksheet indeed is difficult to read when there are tens of lines in there.

We know the Order Tracking line shows the SO No. but it takes too much time.

We have spent days by searching for the way copy the SO No. related in the table but no luck so far.

Perhaps someone knows a simple solution that we couldn't able to imagine.....

Thank you

Joe Kim
joe.kim@alphalabs.co.nz

  • Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 on at
    PO Report Attachment Automatic; Putting SO No. in Planning Worksheet
    What exact page is it where you want to display information about the sales order?
    Can you use ctrl+alt+F1 to find the exact page number?
  • JYKalpha Profile Picture
    JYKalpha 2 on at
    PO Report Attachment Automatic; Putting SO No. in Planning Worksheet
    Hi, 
    Does anyone know about this?
    especially No.2
     
    Thanks!

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

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,540 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans