+ Start a Discussion
Swamy PSwamy P 

Validation for comparing values

Hi,

    i have a situation,i.e when i update a record then it must compare previous value of name with present value of Name.Thus two Names must not be same. For this,i wrote trigger as well as validation.Both are working but when i edit record for changing the other field and i click save,again it shows error.But we dnt want that,we need logic executed only for particular Name updated.

Can anyone suggest me the logic for  validation...

 

 

 

Validation:

AND( ISCHANGED( Name ) ,  NOT(PRIORVALUE( Name )   =    Name)  )

 

Mukul MudgalMukul Mudgal

You don't need NOT(PRIORVALUE( Name )   =    Name) in this scenario.

 

just use ISCHANGED( Name ) function if you just want to check if Name value is changed or not.

Swamy GeorgeSwamy George

Hi Mukul,

                      If i use  ISCHANGED( Name ) ,it reflects true or false only.But i need comparison also i.e,Compare old value with new value for Particular "Name"  field...If those are same,it must through an error i.e,

                                 "You are not changing Name,So change it first".

If prior  value and present  values are different ,save the record in normal..

Mukul MudgalMukul Mudgal

ISCHANGED( Name ) function will return True only when 'Name' field is  changed so there is no need for comparision with prior value. As far as I understand your issue is that you want to check name when you are actually modifying other record fields, so in that case you should check  ISCHANGED( other records fields ) and then compare prior Name value and current Name value.