function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nagarjuna gurajanagarjuna guraja 

Need Trigger and some clarification

1.Write a trigger such that there is checkbox field on User,Account,Contact. Whenever we check the checkbox field on Contact, automatically Account and User should also get updated.
2.How can we able to display 70000 records on visualforce page?
 Best Regards,
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Nagarjuna,

How is Contact related to the user. Are you refering to the CommunityUser.

Regarding the question 2 please find the below link.

https://developer.salesforce.com/forums/?id=906F0000000BZqaIAG

Once you provide the detail on the first point so I can share the trigger for the same.

Thanks,
 
CharuDuttCharuDutt
Hii Nagarjuna
Try Below Trigger
trigger checkboxtrigger on Contact (after insert,after update) {
    set<Id>userId = new set<Id>();
    set<Id>AccId = new set<Id>();
    if(Trigger.IsAfter){
        if(Trigger.IsInsert){
            for(Contact Con : Trigger.New){
                if(Con.CheckBox__c = true){
                    userId.add(Con.OwnerId);
                    AccId.add(Con.AccountId);
                }
            }
        }else if(Trigger.IsUpdate){
            for(Contact Con : Trigger.New){
                if(Con.CheckBox__c = true && Con.AccountId != trigger.oldMap.get(Con.Id).AccountId){
                    userId.add(Con.OwnerId);
                    AccId.add(Con.AccountId);
                }
            }
        }
    }
    list<Account>lstAccount = [Select Id,checkbox__c ,(Select Id,AccountId,CheckBox__c From Contacts) From Account Where Id in :AccId];
    list<User>lstUser = [Select Id,checkbox__c From User Where Id in :userId];
    for(Account Acc : lstAccount){
        for(Contact Con : Acc.Contacts){
            if(Con.AccountId == Acc.Id && Con.checkbox__c == true){
                Acc.checkbox__c = true;
            }
        }
    }
    for(user usr : lstUser){
        usr.checkbox__c = true;
    }
    if(!lstAccount.isEmpty()){
        update lstAccount;
    }
    if(!lstUser.isEmpty()){
        update lstUser;
    }
}
Please Mark It As Best Answer If It Helps
Thank You!
nagarjuna gurajanagarjuna guraja
How can we display more than 70000 records on VF page
nagarjuna gurajanagarjuna guraja
Can we share records using profiles.Please reply to my question