Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
HI
Iam looking to add an error when customerNote__c object records is edited only when createdBy= UserInfo.getuserId
CAn you correct it
trigger updateInvalid on CustomerNote__c (before update) {for (CustomerNote__c opp: trigger.new){System.debug('User:::::'+ UserInfo.getUserId());if (Opp.CreatedById != UserInfo.getUserId()) {opp.adderror('Insufficient Access to edit this Note');}}}
Try the below code
trigger updateInvalid on CustomerNote__c (before update) {for (CustomerNote__c opp: trigger.new){System.debug('User:::::'+ UserInfo.getUserId());if (Opp.CreatedById != UserInfo.getUserId()) {trigger.new[0].adderror('Insufficient Access to edit this Note');}}}
What is the error you are getting,I see your code is fine and it works fine for me ..
Does it works for Bulk updates?
Yes,
It will work for bulk updates too.
CAn you correct it
trigger updateInvalid on CustomerNote__c (before update) {
for (CustomerNote__c opp: trigger.new){
System.debug('User:::::'+ UserInfo.getUserId());
if (Opp.CreatedById != UserInfo.getUserId()) {
opp.adderror('Insufficient Access to edit this Note');
}
}
}
Try the below code
trigger updateInvalid on CustomerNote__c (before update) {
for (CustomerNote__c opp: trigger.new){
System.debug('User:::::'+ UserInfo.getUserId());
if (Opp.CreatedById != UserInfo.getUserId()) {
trigger.new[0].adderror('Insufficient Access to edit this Note');
}
}
}
What is the error you are getting,I see your code is fine and it works fine for me ..
Does it works for Bulk updates?
Yes,
It will work for bulk updates too.