Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to make multiple warnings appear on form

(0) ShareShare
ReportReport
Posted on by 1,313
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.
  • Suggested answer
    Hana Xue Profile Picture
    Hana Xue Microsoft Employee on at
    How to make multiple warnings appear on form
    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

     
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,979 Super User 2025 Season 1 on at
    How to make multiple warnings appear on form
    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
     

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans