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
0
Comments
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.
KCP Consultores
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
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.
KCP Consultores
RIS Plus, LLC
More than one way to skin a cat. For once you and I are both correct!
KCP Consultores
:thumbsup:
I was just about to write the same thing.
KCP Consultores
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.
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
Kavita Mutha
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.
KCP Consultores
It is working fine. After a good sleep last night, I was able to solve it by myself.
Thanks
Liizz
This solution you gave, I had tried it before but it did not work.
Thanks again..
Only 1 NOT is sufficient and the whole statement should be within that NOT.
Liizz