Axaptapedia is now maintained by AgileCadence For more information please click here.

Mandatory DialogField

From Axaptapedia
Revision as of 10:57, 2 May 2006 by 84.245.154.34 (Talk)

Jump to: navigation, search

When adding controls to a standard form, either bound to a data field or not, one useful property is the Mandatory property. If this is set, then the control is shown with a red squiggly line if no value has been entered, and an error will automatically be shown when the user tries to save the record or close the form. This article describes how to also make this functionality available from dialog forms. You need to define the mandatory property in a DialogField class, as shown below.

1. Add mandatory() method into DialogField class: <xpp> // Created by GRR on 01.11.2005 void mandatory(boolean r) {

   str name;
   // If properties exists then we are on server
   if (properties)
   {
       name = #Propertymandatory;
       if (! properties.exists(name))
           properties.add(name,true);
       properties.value(name,r);
   }
   else
       this.fieldControl().mandatory(r);

} </xpp>

2. Add into unpack() method following lines: <xpp> case #PropertyMandatory:

   this.mandatory(unpackedProperties.valueIndex(i));
   break;

</xpp>


This solution was sourced from a post by Regards! Ruslan on the the microsoft.public.axapta.programming newsgroup.