You need to sign in to do that
Don't have an account?
Vidya H 4
hi, anybody can help me for this?
Please anbody help me to write handler class??
trigger OppValidation on Opportunity (before insert,before update) {
Id profileId= userinfo.getProfileId();
String profileName=[Select Id,Name from Profile where Id=:profileId].Name;
if(Trigger.isupdate){
for(Opportunity opp:Trigger.new){
opportunity oldoppy= Trigger.oldmap.get(opp.id);
if(opp.Active__c ==false && oldoppy.Active__c==True && opp.stagename!='Closed Won' && profileName!='System Administrator'){
opp.adderror('You do not have the access to perform this operation. Kindly contact your system administrator');
}
}
}
if(Trigger.isinsert){
for(Opportunity opp:Trigger.new){
if(opp.Active__c ==false && opp.stagename!='Closed Won' && profileName!='System Administrator'){
opp.adderror('You do not have the access to perform this operation. Kindly contact your system administrator');
}
}
}
}
trigger OppValidation on Opportunity (before insert,before update) {
Id profileId= userinfo.getProfileId();
String profileName=[Select Id,Name from Profile where Id=:profileId].Name;
if(Trigger.isupdate){
for(Opportunity opp:Trigger.new){
opportunity oldoppy= Trigger.oldmap.get(opp.id);
if(opp.Active__c ==false && oldoppy.Active__c==True && opp.stagename!='Closed Won' && profileName!='System Administrator'){
opp.adderror('You do not have the access to perform this operation. Kindly contact your system administrator');
}
}
}
if(Trigger.isinsert){
for(Opportunity opp:Trigger.new){
if(opp.Active__c ==false && opp.stagename!='Closed Won' && profileName!='System Administrator'){
opp.adderror('You do not have the access to perform this operation. Kindly contact your system administrator');
}
}
}
}
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!