You need to sign in to do that
Don't have an account?
ExploreForce
To skip validation rule for Users in PermissionSets
trigger OpportunityBeforeUpdate on Opportunity (before update) {
//Update Account Global account
List<Opportunity> listOpp = new List<Opportunity>();
if(trigger.isBefore)
{
if(Trigger.isUpdate)
{
for(Opportunity fOpp: trigger.new)
{
if(fOpp.StageName != trigger.oldmap.get(fOpp.Id).StageName)
listOpp.add(fOpp);
}
}
}
//list<PermissionSet> lstPermissionSets=[Select Name,Id From PermissionSet where Name='Opportunity_Users_Permission_sets'];
list<PermissionSetAssignment> lstPermSets=[select PermissionSet.Name from PermissionSetAssignment
where Assignee.Id = :UserInfo.getUserId()
AND PermissionSet.Name='Opportunity_Users_Permission_sets'];
system.debug('>>>>>>>lstPermSets>>>>'+lstPermSets);
if(lstPermSets.size()>0 && listOpp.size()>0)
{
Opportunity nOpp=[select Id,SkipStage__c,StageName from Opportunity where Id=:listOpp];
system.debug('>>>>>>>Opportunity STAGE CHNAGE>>>>');
//nOpp.SkipStage__c= true;--I need to set(boolean) this to true to skip validation.
//update nOpp;
}
Please anyone can suggest, how to skip validtion rule for users in permissionsets .
//Update Account Global account
List<Opportunity> listOpp = new List<Opportunity>();
if(trigger.isBefore)
{
if(Trigger.isUpdate)
{
for(Opportunity fOpp: trigger.new)
{
if(fOpp.StageName != trigger.oldmap.get(fOpp.Id).StageName)
listOpp.add(fOpp);
}
}
}
//list<PermissionSet> lstPermissionSets=[Select Name,Id From PermissionSet where Name='Opportunity_Users_Permission_sets'];
list<PermissionSetAssignment> lstPermSets=[select PermissionSet.Name from PermissionSetAssignment
where Assignee.Id = :UserInfo.getUserId()
AND PermissionSet.Name='Opportunity_Users_Permission_sets'];
system.debug('>>>>>>>lstPermSets>>>>'+lstPermSets);
if(lstPermSets.size()>0 && listOpp.size()>0)
{
Opportunity nOpp=[select Id,SkipStage__c,StageName from Opportunity where Id=:listOpp];
system.debug('>>>>>>>Opportunity STAGE CHNAGE>>>>');
//nOpp.SkipStage__c= true;--I need to set(boolean) this to true to skip validation.
//update nOpp;
}
Please anyone can suggest, how to skip validtion rule for users in permissionsets .
We can't skip the validation rule, because the order of execution is first before trigger fired then validation rule will be fired.
So add the validation rule functionality in your apex trigger.
For your reference https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_order_of_execution.htm
I think it will be helpful for you.