Apex Triggers - 42 (Trigger Interview Question)

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ต.ค. 2024

ความคิดเห็น • 10

  • @arunimakashyap6207
    @arunimakashyap6207 9 หลายเดือนก่อน +2

    Great video.

    • @sfdcninjas
      @sfdcninjas  9 หลายเดือนก่อน

      Thanks!

  • @abhijit14820
    @abhijit14820 9 หลายเดือนก่อน +1

    Sir Could you please explain below trigger scenario
    write a trigger to update number of opportunities assigned to a user in a custom tab.
    Note : it should increase count if any opportunities created and assigned to user and it should increase and decrease if the the opportunity transferred from one user to another

    • @sfdcninjas
      @sfdcninjas  9 หลายเดือนก่อน

      Hi abhijit sorry for late reply, i will create a video on this scenario for sure just give me some time bro.

    • @abhijit14820
      @abhijit14820 9 หลายเดือนก่อน

      @@sfdcninjas No worries sir... Will wait for the video... Thank you for accepting my scenario question sir🙏

    • @abhijit14820
      @abhijit14820 6 หลายเดือนก่อน

      ​@@sfdcninjasHi Sir... If possible could you do video one, please!

  • @goldylodhi2116
    @goldylodhi2116 9 หลายเดือนก่อน +1

    Nice explanation

    • @sfdcninjas
      @sfdcninjas  9 หลายเดือนก่อน

      Keep watching

  • @memesv3.093
    @memesv3.093 9 หลายเดือนก่อน

    A simpler version of the abpve code (Feedback or suggestions are welcomed):
    trigger AccountTrigger on Account (before update) {

    Set accIds = new Set();

    if(Trigger.isBefore && Trigger.isUpdate){

    for(Account a: Trigger.new){
    if(Trigger.oldMap.get(a.Id).Active__c == 'Active' && a.Active__c == 'Inactive')
    accIds.add(a.Id);
    }



    List conList = [Select Id from Contact where AccountId IN: accIds and Primary_Contact__c=true];

    for(Account a: Trigger.new){
    if(Trigger.oldMap.get(a.Id).Active__c == 'Active' && a.Active__c == 'Inactive')
    {
    if(conList.size() > 0){
    a.addError('You cannot delete this Acc since it contains a Primary contact');
    }
    }
    }
    }
    }