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

how to restrict the Salesforce Platform User to update record using trigger
Hi Everyone,
I am trying to reproduce the scenario as below link. Created a user as Salesforce Platform licence, trigger and when I logged in as Salesforce Platform User licence and created contact and updated not able to get the error.
https://www.sundoginteractive.com/blog/triggers-updating-restricted-records
Can anyone suggest me on this?
Thanks,
Sirisha
I am trying to reproduce the scenario as below link. Created a user as Salesforce Platform licence, trigger and when I logged in as Salesforce Platform User licence and created contact and updated not able to get the error.
https://www.sundoginteractive.com/blog/triggers-updating-restricted-records
Can anyone suggest me on this?
Thanks,
Sirisha
can you post your trigger code such that we can replicate it .
br
Mcoder
Below is the code which will update opportunity flag when user updates any field on Contact Object.
trigger CheckContact on Contact (after update) {
List<ID> acctids = new List<ID>();
List<Opportunity> oppflag = new List<Opportunity>();
for(Contact con:Trigger.New){
acctids.add(con.accountId);
}
if(acctids.size()>0){
List<Opportunity> opplist = [select id,accountid from Opportunity where Accountid In:acctids];
for(Opportunity opp: opplist){
opp.checkflag=true;
oppflag .add(opp);
}
update oppflag ;
}
}
Thanks,
Sirisha
point 1: first checkflag is not a standard filed , it might be a custom one
point2: all ways include fieilds in soql if we use it like below
=============================================================
Using Maps : Trigger always should be buikified
trigger UpdateOppFTPRecipients on Contact (after update) {
List<ID> acctids = new List<ID>();
List<Opportunity> opplist = new List<Opportunity>();
for(Contact con:Trigger.New){
acctids.add(con.accountId);
}
Map<Id,Opportunity> OppMap = new Map<Id,Opportunity>([select id,accountid,FTP_Recipients__c from Opportunity where Accountid In:acctids]);
if(OppMap.size() > 0 )
{
for(Opportunity opp: OppMap.values())
{
if(OppMap.get(opp.id).Accountid!=null)
{
opp.FTP_Recipients__c = true;
opplist.add(opp);
}
}
}
update opplist;
}
==========================================================================
Using list :
trigger UpdateOppFTPRecipients on Contact (after update) {
List<ID> acctids = new List<ID>();
List<Opportunity> oppflag = new List<Opportunity>();
for(Contact con:Trigger.New){
acctids.add(con.accountId);
}
if(acctids.size()>0){
List<Opportunity> opplist = [select id,accountid,FTP_Recipients__c from Opportunity where Accountid In:acctids];
for(Opportunity opp: opplist){
opp.FTP_Recipients__c=true;
oppflag.add(opp);
}
update oppflag ;
}
}
Please mark it as a better solution.
please reach out to me at salesforceseekar@gmail.com if you need help , Happy learning.
br
Mcoder