mibuso.com

Microsoft Business Solutions online community
It is currently Thu Oct 30, 2014 7:09 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Validation on option fields is not working.
PostPosted: Tue May 29, 2012 8:24 pm 
Offline

Joined: Thu Dec 16, 2010 7:11 am
Posts: 97
Country: Bangladesh (bd)
Hi all,

I have 3 option fields with their option stings defined too: Status 1(Incomplete, Finish), Status 2(,Postponed, Cancelled) and Status 3(, Approved, Rejected).

Now, the validation is as such: Status 3 can be Approved only if Status 1=Finish and Status 2=Blank.
else it displays an error message.

I have placed codes on Status 3- OnValidate of my customised table
IF NOT("Status 1"="Status 1"::Finish) AND NOT("Status 2"="Status 2"::" ") THEN BEGIN
ERROR('Status 1 should be confirmed and Status 2 should be blank');
END;

But my codes are not working.

Its been a while since am struggling with it ](*,)

Please help.

Thanks
Liizz


Top
 Profile E-mail  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Tue May 29, 2012 8:50 pm 
Offline

Joined: Fri May 18, 2012 2:04 pm
Posts: 148
Location: Armenia, Quindio
Country: Colombia (co)
I am not sure what you mean by it is not working, please elaborate.

I am not sure if you have the check done only if Status 3 is not blank, if not then maybe this is the issue. I have rewritten below also using less characters:

if "Status 3" <> 0 then
IF ("Status 1" <> "Status 1"::Finish) AND ("Status 2" <> "Status 2"::" ") THEN
ERROR('Status 1 should be confirmed and Status 2 should be blank');

I would also replace your error text with a text constant especially if this will ever be used in a multi-language environment.

_________________
Gerry Kistler
KCP Consultores


Top
 Profile E-mail  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Tue May 29, 2012 9:23 pm 
Offline

Joined: Thu Dec 16, 2010 7:11 am
Posts: 97
Country: Bangladesh (bd)
Thanks for your reply. Sorry for not making myself clear in my query..

IF the field Status 1 is Finish and field Status 2 is blank, then field Status 3 can be set to Approved.
If not, show an error message.

I can not have this scenario:
Status 1:Incomplete
Status 2: ' '
This test case should prompt me an error message..

Yes in my code I have make use of text constant.

I have tried your codes too but the error message is not being fired..

Thanks
Liizz


Top
 Profile E-mail  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Tue May 29, 2012 10:04 pm 
Offline

Joined: Fri May 18, 2012 2:04 pm
Posts: 148
Location: Armenia, Quindio
Country: Colombia (co)
My mistake, this should work:
if "Status 3" = "Status 3"::Approved then
IF not (("Status 1" = "Status 1"::Finish) AND ("Status 2" = "Status 2"::" ")) THEN
ERROR('Status 1 should be confirmed and Status 2 should be blank');

You need both to be true so the NOT belongs outside of both true statements.

_________________
Gerry Kistler
KCP Consultores


Top
 Profile E-mail  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Tue May 29, 2012 10:43 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Thu Jan 02, 2003 5:37 pm
Posts: 7993
Location: Flagstaff, AZ
Country: United States (us)
Why not:
Code: Select all
IF "Status 3" = "Status 3"::Approved THEN BEGIN
  TESTFIELD("Status 1","Status 1"::Finish);
  TESTFIELD("Status 2","Status 2"::" ");
END;

_________________
Daniel Rimmelzwaan
KCP Dynamics
MVP - Dynamics NAV


Top
 Profile  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Tue May 29, 2012 11:12 pm 
Offline

Joined: Fri May 18, 2012 2:04 pm
Posts: 148
Location: Armenia, Quindio
Country: Colombia (co)
Danster,
More than one way to skin a cat. For once you and I are both correct!

_________________
Gerry Kistler
KCP Consultores


Top
 Profile E-mail  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Wed May 30, 2012 1:15 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Tue Aug 14, 2001 6:01 am
Posts: 5349
Location: Prague
Country: Czech Republic (cz)
DenSter wrote:
Why not:
Code: Select all
IF "Status 3" = "Status 3"::Approved THEN BEGIN
  TESTFIELD("Status 1","Status 1"::Finish);
  TESTFIELD("Status 2","Status 2"::" ");
END;


:thumbsup:
I was just about to write the same thing.

_________________
David Singleton
Dynamics NAV Freelancer
Dynamics Book
Go-Live International


Top
 Profile E-mail WWW  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Wed May 30, 2012 1:32 am 
Offline

Joined: Fri May 18, 2012 2:04 pm
Posts: 148
Location: Armenia, Quindio
Country: Colombia (co)
The difference is if you want to display a more descriptive error message of your own creation, or if the standard TESTFIELD error is enough for the user to understand what they did wrong.

_________________
Gerry Kistler
KCP Consultores


Top
 Profile E-mail  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Wed May 30, 2012 1:42 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Tue Aug 14, 2001 6:01 am
Posts: 5349
Location: Prague
Country: Czech Republic (cz)
gerrykistler wrote:
The difference is if you want to display a more descriptive error message of your own creation, or if the standard TESTFIELD error is enough for the user to understand what they did wrong.


Yes that's correct. The problem is that there are so many cryptic error messages in Navision, that users come to expect them. And this way they learn what they did wrong at each step. First you get the message that you made mistake X then a message you made mistake Y. Most users learn faster than being told you made X and Y mistakes please fix them.

But it does come down a lot to personal preferences. And its really two issues, one being do you want two separate messages or one big one. The other option is to you FIELDERROR, but you don't see the new generation of developers using that much.

_________________
David Singleton
Dynamics NAV Freelancer
Dynamics Book
Go-Live International


Top
 Profile E-mail WWW  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Wed May 30, 2012 7:49 am 
Offline

Joined: Fri Dec 16, 2011 8:22 am
Posts: 60
Country: India (in)
Hi Liizz,

As per your requirement the following code should be work...

Status3 - OnValidate()

IF Status3 = Status3::Approved THEN
IF NOT (Status1 = Status1::Finish) AND NOT (Status2 = 0) THEN
ERROR('Status 1 should be confirmed and Status 2 should be blank');

Let me know the result :)

Best Regards,
Kavita Bavkar

_________________
Best Regards,
Kavita Mutha


Top
 Profile E-mail  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Wed May 30, 2012 11:22 am 
Offline

Joined: Fri May 18, 2012 2:04 pm
Posts: 148
Location: Armenia, Quindio
Country: Colombia (co)
Kavita,
That actually does not work as described by the OP and I missed on my first response. Having the NOT on both cases does not cover all situations as it could be Finished and NOT Blank therefore pass the test which is not what the OP was looking for. It needs to test one situation only, Finished and Blank and only if those two conditions are true, then no error. This means the NOT (Finished and Blank) is what is needed in this case.

_________________
Gerry Kistler
KCP Consultores


Top
 Profile E-mail  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Wed May 30, 2012 12:39 pm 
Offline

Joined: Thu Dec 16, 2010 7:11 am
Posts: 97
Country: Bangladesh (bd)
Thanks to all for your replies.

It is working fine. After a good sleep last night, I was able to solve it by myself. :D

Thanks
Liizz


Top
 Profile E-mail  
 
 Post subject: Re: Validation on option fields is not working.
PostPosted: Wed May 30, 2012 5:41 pm 
Offline

Joined: Thu Dec 16, 2010 7:11 am
Posts: 97
Country: Bangladesh (bd)
Hi Kau_147,

This solution you gave, I had tried it before but it did not work.

Kau_147 wrote:
Status3 - OnValidate()
IF Status3 = Status3::Approved THEN
IF NOT (Status1 = Status1::Finish) AND NOT (Status2 = 0) THEN


Thanks again..
Only 1 NOT is sufficient and the whole statement should be within that NOT.

Liizz


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Exabot [Bot] and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: