You need to sign in to do that
Don't have an account?
Abraham Durojaiye
How to set up a trigger to restrict an Opportunity record to only the Opportunity owner and team members listed by selecting a custom checkbox field.
Hi All,
I have created a custom checkbox field in the Opportunity object called "Confidential". The purpose of this checkbox is to restrict access to the record to only the Opportunity owner and any listed team members in that Opportunity when the checkbox is selected.
Please advise on how I can do this.
Thanks
I have created a custom checkbox field in the Opportunity object called "Confidential". The purpose of this checkbox is to restrict access to the record to only the Opportunity owner and any listed team members in that Opportunity when the checkbox is selected.
Please advise on how I can do this.
Thanks
You can write a triggerfor this.
Whenever the field is checked then write a trigger that prevents from editing/Deleting the record.Other than record owner
Thanks
Can you please assist me with the specific trigger I should use, i.e. can you please indicate the entire trigger?
Thanks
set<Id> setopptyId = new set<Id>();
set<Id> UserId = new set<Id>();
string u= userinfo.getUserId();
for(opportunity opp:trigger.old){
list<opportunity>ListOpp= new list<opportunity>([select Id,ownerId,confident__c from opportunity
where confident__c=true and
OwnerId != :U]); {
setopptyId.add(opp.Id);
}
}
Map<Id,opportunity> oppy = new Map<Id,opportunity>([Select Id,ownerId,confident__c from opportunity
Where Id In :setopptyId limit 1]);
for(opportunity o: trigger.old){
if(oppy.get(o.Id).confident__c && oppy.get(o.Id).OwnerId != U){
o.addError('cant delete the opportunity');
}
}
}
Thank you for sharing the trigger with me. Can you please instruct me also on how I can test this trigger in sandbox before pushing to production?
I seem to be doing something wrong.
Thanks.