on 06-22-2010 2:01 PM
Hello Folks,
i just started working with Validations..
when i have gone through the syntax of IF then stattement,
But i am struggling to implement it after i see some examples in Complete reference 7.1 like IF(F1, F2)
F1 is true ->f2
f1 is false ->NULL
Can anyone explain with a practical real time condition
Thanks in Advance.
KR
John
Hi ,
First thing about validation expression is always return bollean value i.e. either true or false.
So during writing expreesion plz take care of this thing.
Example IF(n1,v2)
n1 - must be a bolean value like (supplier.name="name1").this either true or false
v2 - incase of assignment it can be any value but if you are using with validation then as this is returning value then it must be either "TRUE" or "FALSE"
you can go through this article you will get some knowledge
Hope this will help you and if your prob is resolved then please close this thread.
If you need some more info then please get back to us.
Thanks,
Sudhanshu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
n1 - must be a bolean value like (supplier.name="name1").this either true or false
v2 - incase of assignment it can be any value but if you are using with validation then as this is returning value then it must be either "TRUE" or "FALSE"
Can you substantiate your above statement with an example.
onthe otherhand
when you say validation writes true or false that means it creats a colums and confirms whether that record is success via validation or not. Right!!!!!!
KR
John
Hi John,
Yes in case of validation faliure or succes mdm creates a one new coloumn with coloumn header name the validation name that you run against records.
If validation successful the a right tick in gren color will come into coloumn corresponding to successfull records and a red cross for each failed record.
Example :Like i have a test field in maintable and you want that noone record cotain "xyz" value for this field then in that case we will create a validation like
if(fieldname="XYZ",false) ; //for ifthen case
if(fieldname="XYZ",false,true) ; //for ithenelse case
Hope you understand the case.
Thanks,
Sudhanshu
Hello,
if(fieldname="XYZ",false) ; //for ifthen case
if(fieldname="XYZ",false,true)
I executed both examples and they are working fine. Thanks.
But i have seen a validation in Complete reference 7.1 ''
IF(IS_NULL(FIELD1), "???", FIELD1)
if field 1 is NULL --> "???"
OTHERWISE ---> field1
What does this mean..
Can anyone explain!!!!
KR
John
Hi Eva,
What is mentioned on this page 252 is general expression not validation expression.
IF(IS_NULL(Desc), u201C???u201D, Desc)
in that IF THEN ELSE statement they are telling that if value of field Desc has NULL value then assign "???" string to field
Desc otherwise assign same value that Desc value have.
I think this clear your doubts.
Thanks,
Sudhanshu
Hello,
Lets say my table has a field 'DESC'
DESC
-
1001
1002
1004
Four records of which 3 rd record is Empty.
Now if I run the below validation..
IF(IS_NULL(Desc), u201Chellou201D, Desc)
what will be theresult?
will my 3rd record be filled with 'hello' ???
Onthe otherhand,
'If' my Desc field has all four records filled,
and if i run this validation then what happens???
You said 'assign same value that Desc value have.' !!!
What will be the output in this case.
Experts please have a look
KR
John
HI John,
First i want to clear one thing .
With assignment expression only you can assign values to field
with validation expression you only check whether that record is valid against that expression or not.
Now as i already told you that is assignemnt expression not validation expression
If you run this expression in assignemnt then yes it will assign the value"hello" to third record .
This is not a valid validation expresiion because the output of validation expression must be boolean value.
Valid validation expression is
IF(IS_NULL(Desc), false,true)
In this case when you run this validation aginst records then if that record contain value then a green right tick will come otherwise red cross will come and laso it depends upon how you create a validation expression property "automatica execution".
Hope i answered your question.
Thanks,
Sudhanshu
Hi John,
IF(IS_NULL(Desc), u201Chellou201D, Desc)
1stly, you should understand that this is a expression which can be used in Assignment or Validation.
Since Validation always return True or False, so if you are using expression in Validation, it should be like this
IF(IS_NULL(Desc), TRUE, FALSE) or IF(IS_NULL(Desc), FALSE, TRUE)
so whenever your logic passes it goes to then if fails go to Else.
In your case, if you use this expression in your validation, IF(IS_NULL(Desc), u201Chellou201D, Desc)
You will always get FALSE, fail records because as validation returns true or false, its then and else statement should have TRUE or False as suggested above.
But if you use in this Expression in Assignment, IF(IS_NULL(Desc), u201Chellou201D, Desc)
It will populate your 3rd record with hello and values which are already populated(Not Null), it will keep those values of Desc.
Also make sure that during Assignment, your Assignment Field = DESC
Regards,
Mandeep Saini
Hello,
Thanks for taking that extra pain in explaining the issue.
I have a field where there are 4 records
Name
-
1
2
4
*3rd is Null.
Now wen i run a validation expression IF THEN
IF(IS_NULL(NAME),TRUE)
I can see that all the four records have a success symbol.
Where in my condition says If null then Success right!!!
why are the other 3 records which have values in them are also success.
Please answer.
KR
John
Hi John,
Please refer my above post, hope it will clear your doubts.
IF(IS_NULL(NAME),TRUE)
For Validation, you should either write expression as
IS_NULL(NAME)
OR
IF(IS_NULL(NAME),TRUE , FALSE )
Since Validation expression Returns either TRUE or FALSE, you need to tell if your logic passes(PASS/FAIL) then what should return if its PASS mean TRUE/FALSE and what should return if it FAILS mean FALSE/TRUE
Regards,
Mandeep Saini
Fully agree with you.
But my question is ..
i have a field where there are 4 records
Name
-
1
2
4
*3rd is Null.
Now wen i run a validation expression IF THEN
IF(IS_NULL(NAME),TRUE)
I can see that all the four records have a success symbol.
Where in my condition says If null then Success right!!!
why are the other 3 records which have values in them are also success.
John
Hi John,
IF(IS_NULL(NAME),TRUE)
According to this Expression it tells when there is null value for field NAME then returns TRUE which mean Success but you didn't tell what should be done if this field NAME has value, that's why you are getting Success for Every record.
In other words, if you give expression as IF(IS_NULL(NAME),FALSE), it will gives always FALSE as you havent tell what should be happen if it has value.
So you need to tell bth TRUE and FALSE in your Expression to accurately make use of Validations.
IF(IS_NULL(NAME),TRUE, FALSE)
Here, it gives TRUE (Success) for 3 rd record only,
And other 3 records which have values in them should be FALSE as you given in Exprssion if it has no value return TRUE(Success) and if it has Value Return FALSE
Hope you got my point !!
Regards,
Mandeep Saini
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.