With sharing doesn't work with triggers

Sample Code:


trigger sample on Account (after insert, after update) {


public with sharing class Sample1{
    public static void test(List<Account> acctList){
        List<Employee__c> empList = new List<Employee__c>();
        for(Account a : acctList){
            Employee__c e = new Employee__c(Name = 'Testing');
        insert empList; 

If an user with no access to Employee object creates an account or updates an account, Employee record with the name, "Testing" will be created with created by name as him/her.

With Sharing doesn't work with triggers.


No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit