• Swamy George
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies

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)  )

 

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 trigger or validation...

 

Trigger:

trigger old_New_comparison on Employee__c (after update) {
for(Employee__c e:Trigger.New){
Employee__c oldvalue=trigger.oldMap.get(e.id);
if(e.Name==oldvalue.Name){
e.Name.adderror('Please Change the Name');

}
}

 

Validation:

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