web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to make multiple warnings appear on form

(0) ShareShare
ReportReport
Posted on by 2,025
Hi,

I wrote code to do some validations when confirming the PO. So When I click /confirmation/ button on the purch order form, the dialog appears and i click ok, I'm expecting some warnings to appear based on the code i added on the cofirmation action.

However, I noticed that not all warnings appear on the UI, why?? For example i was expecting 4 warnings to appear on the UI. However, only one appeared and the rest of the three appeared in the notification center. why they didn't all appear in the form?


 
[ExtensionOf(classStr(PurchFormLetter_PurchOrder))]
final class PurchFormLetter_PurchOrderX_Extension
{
    private boolean must = false;

    public boolean  validate(Object _calledFrom)
    {
        boolean ret;
        
        ret = next validate(_calledFrom);
        if(ret)
        {
            PurchLine purchLine;
            while select purchLine where purchLine.PurchId == this.PurchTable().PurchId
            {
                TableX tableX;
                select firstonly tableX where tableX.ItemId == purchLine.ItemId;
                if(tableX)
                {
                    this.validateFirstField(purchLine, tableX);
                    this.validateSecondField(purchLine, tableX);
                }
            }
 
           if(must)
           {
              throw error(/fix all errors/);
           }
        }
        return ret;
    }
 
    public void validateFirstField(PurchLine _purchLine, TableX _tableX)
    {
        if(_tableX.FirstField == XType::Must && _purchLine.FirstField== '')
        {
             error(strFmt(/The FirstField for itemId: %1,  is must be filled/, _purchLine.ItemId));
             must = true;
        }
        else if(_tableX.FirstField == XType::Optional && _purchLine.FirstField== '')
        {
            warning(strFmt(/The FirstField for itemId: %1,  is preferred be filled/, _purchLine.ItemId));
        }
    }
    public void validateSecondField(PurchLine _purchLine, TableX _tableX)
    {
        if(_tableX.SecondField == XType::Must && _purchLine.SecondField == '')
        {
            error(strFmt(/The SecondField for itemId: %1,  is must be filled/, _purchLine.ItemId));
            must = true;
        }
        else if(_tableX.SecondField == XType::Optional && _purchLine.SecondField == '')
        {// 
            warning(strFmt(/The SecondField for itemId: %1,  is preferred be filled/, _purchLine.ItemId));
        }
    }
}
 
// i also tried to store all warnings in a variable and loop through them but same thing happened.
  • André Arnaud de Calavon Profile Picture
    307,765 Super User 2026 Season 2 on at
    Hi IntegrationBeginner,
     
    We were discussing this already in another question. Please don't duplicate your questions on the forum. You are leaving some interesting details out. Let's continue the discussion on this thread: PurchLines validation when confirming the oder - Dynamics Community Forum Thread Details
     
  • Suggested answer
    Hana Xue Profile Picture
    Microsoft Employee on at
    Hi,
    If you have already discussed this issue in the forum, please keep one thread to discuss it to avoid thread abuse. Thanks for your understanding.
    Best Regards,
    Hana

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 582 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 410 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 185

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans