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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Warning message while opening a form

(0) ShareShare
ReportReport
Posted on by 6

Hi,

I have to generate a warning message while opening a form to all the users based on some conditions ( For eg: If one date is due in the vendor form, users should get warning message while they open the Vendor form )

Alert won't work in this case, I already tried it. I already tried message box option also, but I don't know where to write the code for that. 

Your help will be highly apprecuated.

Thanks

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi,

    You need to write the code in the init method of the form. You can see lot of standard form validate the caller record and if the caller record is null it will throw an error. Likewise, you can add.

    You can refer to standard PayrollWorkerTaxCode >> Init method of the form.

    public void init()
    {
        if (condition)
        {
            throw error("@SYS22539");
        }
        super();
    }

    Thanks,

    Girish S.

  • GirishS Profile Picture
    27,827 Moderator on at

    Sorry It will be warning not throw error. Also, if the user selects any other vendor you need to validate them against the vendor also. So you need to add the code in the active method of the form. If the user changes the vendor active method will be called and warning will be thrown.

    Thanks,

    Girish S.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, Do you need to check date for selected vendor or all vendors? You need to write code in init method of VendTable datasource and add warning for selected vendor. If you need to show warning for all vendors then loop all vendors in VendTable where condition is failing.

  • GirishS Profile Picture
    27,827 Moderator on at

    You need to consider the performance when adding looping in the init method of the form. It will consume more time to open the form.

    If you are okay with it you can go with init method - Loop all the records and add validation.

    Thanks,

    Girish S.

  • neethukbabu Profile Picture
    6 on at

    Hi,

    Thanks Girish.

    Users should get notifications for all the vendors who are not meeting the condition.

    If(today > date)

    {

    info("Warning message")

    }

    I want to write above code in the form init, but I am not able to get the date field there.

    Please help me, I am not much familiar with the coding.

  • GirishS Profile Picture
    27,827 Moderator on at

    If you want to throw warning for all the vendors while opening the form, you need to add while select statement in the init method of the form.

    Public void init()
    {
        VendTable vendTable;
        
        while select * from vendTable
        {
            //I am assuming there is date field in vendTable.
            if(vendTable.ExpiryDate < today())
            {
                info(strfmt("%1", throw warning message here));
            }
        }
    }

    Thanks,

    Girish S.

  • neethukbabu Profile Picture
    6 on at

    Hi,

    Thanks Mohit.

    I want it for all the vendors.

    If you are providing the coding, it will be grateful as I am not familiar with the coding.

    We have added new field in the vendtable for trade License expiry date and if it expires, users should get warning message if they are opening the Vendform. This is the actual requirement.

  • GirishS Profile Picture
    27,827 Moderator on at

    Updated the code - Please check and let us know if it meets your scenario.

    Thanks,

    Girish S.

  • neethukbabu Profile Picture
    6 on at

    Hi Girish,

    No. If I am using while statement, I am getting notification for all the vendors in one vendor open form itself. So I removed it. But other issue is, If any one of the vendors expiry date is due, it is throwing warning in all the vendors open page since we are not mentioning the current form vendor in the code. Can i use this.expiryDate? or any other option?

  • GirishS Profile Picture
    27,827 Moderator on at

    If you want your warning message to throw when changing the vendors in the form - You need to add your code in the active method of VendTable form Datasource.

    Thanks,

    Girish S.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans