[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.axapta.programming

Chaning a property value in validateField() - Newbie

T-AIM

10/19/2005 8:42:00 AM

I want to change the property value of a field when a certain condition is
met. I want to change the CreditMax mandatory property to true if it is a
Cash customer.
Am i doing this at the right place? Please advice.

boolean validateField(fieldId p1)
{
boolean ret;

ret = super(p1);

switch (p1)
{
case fieldNum(CustTable, VATNum) :
ret = TaxVATNumTable::checkVATNum(this.VATNum, this, p1);
break;
case fieldNum(CustTable, CustGroup) :
if (this.CustGroup == "Cash")
{
this.MandatoryCreditLimit = 1;
//change the CreditMax mandatory property over here.

}

case fieldNum(CustTable, CreditMax) :
if (this.creditMax < 0)
{
ret = checkFailed("@SYS69970");
}
break;
}

return ret;
}
Many thanks
T-AIM
3 Answers

Luegisdorf

10/19/2005 10:51:00 AM

0

Hi T-AIM

If I understand you right way you want to set a field mandatory at runtime?

I yes, so look your code again with some new code

boolean validateField(fieldId p1)
{
boolean ret;
FormDataSource fds;

ret = super(p1);

switch (p1)
{
case fieldNum(CustTable, VATNum) :
ret = TaxVATNumTable::checkVATNum(this.VATNum, this, p1);
break;
case fieldNum(CustTable, CustGroup) :
if (this.CustGroup == "Cash")
{
this.MandatoryCreditLimit = 1;
if (this.isFormDataSource)
{
fds = this.dataSource();
fds.object(fieldnum(MyTable,
MandaotryCredtLimit)).mandatory(true);
}
//after a field check, the field maybe will mandatory

}

case fieldNum(CustTable, CreditMax) :
if (this.creditMax < 0)
{
ret = checkFailed("@SYS69970");
}
break;
}

return ret;
}

Hope this helps. Feel free to ask if that wasn''t that you want or if you
have further questions.

Best regards
Patrick

> Many thanks
> T-AIM

T-AIM

10/20/2005 9:10:00 AM

0

Thank you so much Patrick, that is excatly what i wanted. I have tested this
but still not forcing the user to input a value > 0.00 Is there a commit just
after setting the property? When will it take effect?

Thank you for all your help.
Kind Regards
T

"Luegisdorf" wrote:

> Hi T-AIM
>
> If I understand you right way you want to set a field mandatory at runtime?
>
> I yes, so look your code again with some new code
>
> boolean validateField(fieldId p1)
> {
> boolean ret;
> FormDataSource fds;
>
> ret = super(p1);
>
> switch (p1)
> {
> case fieldNum(CustTable, VATNum) :
> ret = TaxVATNumTable::checkVATNum(this.VATNum, this, p1);
> break;
> case fieldNum(CustTable, CustGroup) :
> if (this.CustGroup == "Cash")
> {
> this.MandatoryCreditLimit = 1;
> if (this.isFormDataSource)
> {
> fds = this.dataSource();
> fds.object(fieldnum(MyTable,
> MandaotryCredtLimit)).mandatory(true);
> }
> //after a field check, the field maybe will mandatory
>
> }
>
> case fieldNum(CustTable, CreditMax) :
> if (this.creditMax < 0)
> {
> ret = checkFailed("@SYS69970");
> }
> break;
> }
>
> return ret;
> }
>
> Hope this helps. Feel free to ask if that wasn''t that you want or if you
> have further questions.
>
> Best regards
> Patrick
>
> > Many thanks
> > T-AIM

Luegisdorf

10/21/2005 6:29:00 AM

0

Hi T

you need additionally to check if the field is empty or not (to set
mandatory property on a data source just makes some red lines, but not more).

overwrite the data source''s validateWrite() method
(fromXY/DataSources/YourDataSourceTable/methods) and but after ''ret =
super()'' this code:

ret = this.object(fieldnum(MyTable, MandaotryCredtLimit)).mandatory() && !
myTable.MandatoryCreditLimit ? checkfailed(strfmt("@SYS26332", new
DictField(fieldnum(MyTable, MandatoryCreditLimit)).label())) : ret;

I hope the brackets are correct (code was written direct in here ...)

Best regards
Patrick

"T-AIM" wrote:

> Thank you so much Patrick, that is excatly what i wanted. I have tested this
> but still not forcing the user to input a value > 0.00 Is there a commit just
> after setting the property? When will it take effect?
>
> Thank you for all your help.
> Kind Regards
> T
>
> "Luegisdorf" wrote:
>
> > Hi T-AIM
> >
> > If I understand you right way you want to set a field mandatory at runtime?
> >
> > I yes, so look your code again with some new code
> >
> > boolean validateField(fieldId p1)
> > {
> > boolean ret;
> > FormDataSource fds;
> >
> > ret = super(p1);
> >
> > switch (p1)
> > {
> > case fieldNum(CustTable, VATNum) :
> > ret = TaxVATNumTable::checkVATNum(this.VATNum, this, p1);
> > break;
> > case fieldNum(CustTable, CustGroup) :
> > if (this.CustGroup == "Cash")
> > {
> > this.MandatoryCreditLimit = 1;
> > if (this.isFormDataSource)
> > {
> > fds = this.dataSource();
> > fds.object(fieldnum(MyTable,
> > MandaotryCredtLimit)).mandatory(true);
> > }
> > //after a field check, the field maybe will mandatory
> >
> > }
> >
> > case fieldNum(CustTable, CreditMax) :
> > if (this.creditMax < 0)
> > {
> > ret = checkFailed("@SYS69970");
> > }
> > break;
> > }
> >
> > return ret;
> > }
> >
> > Hope this helps. Feel free to ask if that wasn''t that you want or if you
> > have further questions.
> >
> > Best regards
> > Patrick
> >
> > > Many thanks
> > > T-AIM