Skip to main content
Yeturu Srikanth (bigworks) a posé une question dans #Visualforce
public class taskSelectClassController {

     public  Account acct{get; set;}

       public string currentRecordId {get;set;}

       public  List<Id> tasksIds{set;get;} 

       public List<task__c> updatedRecords {get;set;}

        public taskSelectClassController(ApexPages.StandardController stdController) {

           currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');

                tasksIds =new List<Id>();

        

            wraptaskList = new List<wraptask>();

            //-- if task is custom object then, you need to change this query

            //for(task a: [select AccountId,task Name from task limit 10]) 

     

           for(Task__c  a: [select Lookup_Account__c,Name from Task__c Where Lookup_Account__c = null limit 10])  {               

                wraptaskList.add(new wraptask(a));

            }

        }

    

    public List<wraptask> wraptaskList {get; set;}

    public List<task__c> selectedtasks{get;set;}

  

    public void processSelected() {

    selectedtasks = new List<task__c>();

      

        for(wraptask wraptaskObj : wraptaskList) {

            if(wraptaskObj.selected == true) { 

                

                selectedtasks.add(wraptaskObj.acc);

            }

            for(task__c var : selectedtasks)

            {

                tasksIds.add(var.Id);

            }

            List<task__c>taskRecords = [SELECT Lookup_Account__c from task__c where ID IN: tasksIds];

                updatedRecords = new List<task__c>();

            for( task__c chl : taskRecords ) {

            chl.Lookup_Account__c = currentRecordId;

            updatedRecords.add(chl);

               

        }

             update updatedRecords; 

    }

 

    public class wraptask

                          {

        public task__c acc {get; set;}

        public Boolean selected {get; set;}      

        public wraptask(task__c a) {

            acc = a;

            selected = false;

        }

    }

}
2 réponses
0/9000