• seo soe
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi all

  I have two users A and B assigned into the same profile. I need to show different picklist values for different user like VAL1,VAL2 ,VAL 3 for  user A and VAL 4 ,VAL5 for user B. 
Can anybody suggest how to achieve this ? 
trigger TaskTrigger on Task (after insert,before delete,after update) {
    public List<Task> ltask1 = new List<Task>();
    public id acid;
    public integer clo=0;   
    public integer ope=0;
    public integer blk=0;
    if(trigger.isinsert || trigger.isupdate){  
    for(Task t:Trigger.New){
        acid = t.WhatId;
        system.debug('accid'+acid);
        
    }
    ltask1 = [select id,Status from task where whatid=:acid];
    system.debug('acsize'+ltask1.size());
    
    
    for(task t:ltask1){
        if(t.Status=='Completed'){
            clo = clo+1;
            system.debug(clo);
        } else if(t.Status=='In Progress'){
            ope = ope +1;
            system.debug(ope);
        }else if(t.Status=='Deferred')
        {
             blk = blk+1;
            system.debug(blk);
        }                
    } List<Account> acc = new List<Account>();    
    List<Account> ac = [select id from Account where id = :acid];
    system.debug('oppsize'+ac.size());
    for(Account a: ac){
        a.Open_Task__c = ope;
        a.Closed_Tasks__c = clo;
        a.Blocked_Tasks__c=blk;
        acc.add(a);  
    } if(acc.size()>0){
        update acc;
    }   
    }
        //ltask = [select id,Status from task where whatid=:acid];
        
   
   
    if (Trigger.isDelete){
              for (Task t : trigger.Old) {
                   acid=t.whatid;
               }
    ltask1 = [select id,Status from task where whatid=:acid];
    system.debug('acsize'+ltask1.size());
    
    
    for(task t:ltask1){
        if(t.Status=='Completed'){
            clo = clo-1;
            system.debug(clo);
        } else if(t.Status=='In Progress'){
            ope = ope -1;
            system.debug(ope);
        }else if(t.Status=='Deferred')
        {
             blk = blk-1;
            system.debug(blk);
        }                
    } List<Account> acc = new List<Account>();    
    List<Account> ac = [select id from Account where id = :acid];
    system.debug('oppsize'+ac.size());
    for(Account a: ac){
        a.Open_Task__c = ope;
        a.Closed_Tasks__c = clo;
        a.Blocked_Tasks__c=blk;
        acc.add(a);  
    } if(acc.size()>0){
        update acc;
    }   
    }
      
    system.debug('No of Tasks'+ope+ clo+blk);

    }