You need to sign in to do that
Don't have an account?

convert validation rule to trigger
Hi All,
I am very new to development and aI have to change one validation rule on Opportunity into trigger using custom settings.
For example:Validation rule on an opportunity has some profiles, some roles and stage
something like below-
AND(
ISPICKVAL(StageName ,"Pending"),
ISPICKVAL(StageName ,"Closed") ,
NOT($Permission.Bypass_Rule_Exclusion),
$Profile.Name <> " Contractor",
$UserRole.Name <> "Analyst")
and I need to change this validation rule into trigger.
I can move this hardcoded values to custom settings,but I am not sure how to write a trigger .
Could someone please help me.
I am very new to development and aI have to change one validation rule on Opportunity into trigger using custom settings.
For example:Validation rule on an opportunity has some profiles, some roles and stage
something like below-
AND(
ISPICKVAL(StageName ,"Pending"),
ISPICKVAL(StageName ,"Closed") ,
NOT($Permission.Bypass_Rule_Exclusion),
$Profile.Name <> " Contractor",
$UserRole.Name <> "Analyst")
and I need to change this validation rule into trigger.
I can move this hardcoded values to custom settings,but I am not sure how to write a trigger .
Could someone please help me.
Asssuming you want the validation to fire on both Update and Insert you can use the below code. I have modified the code to meet your requirements. Please select this as best answer if the solution works for you.
All Answers
Asssuming you want the validation to fire on both Update and Insert you can use the below code. I have modified the code to meet your requirements. Please select this as best answer if the solution works for you.
Thanks for all your help.
Could you please let me know how to write test class for this trigger?
This is my first test class and Trigger.
Appreciate all your help