Skip to main content
sandeep reddy ha fatto una domanda in #Apex
hi 

i am srinu 

i wrote  the code for retrive  records from account then if no records then creats arecord

what was the  wrong in this 

public class queablejob  implements Queueable {

    public list<account>ac{set;get;}

    public void search(){

       account acc=[select id  name ,fax,rating from account];

        ac=new list<account>ac();

        list<account> ac{acc};

            

    }

    public void execute( queablejob quee){

        if(SEARCH()=null){

        account a=new account(Name ='part',email='rapatan@gmail.com' ,rating='hot');

        insert a;

        upsert a;

        }

        else

        {

            list<account>ac;

            system.dubug('the  accounts '+ ac );

            

        }

        

        

    }

}
3 risposte
  1. 16 feb 2016, 07:50
    Hi Srinu

              Try following code

    public class queablejob  implements Queueable {

        public list<account>ac{set;get;}

        public void search(){

           account acc=[select id ,name ,fax,rating from account];

            ac=new list<account>{acc};

            //list<account> ac{acc};

                

        }

        public void execute( QueueableContext quee){

        SEARCH();

            if(ac == null){

            account a=new account(Name ='part' ,rating='hot');

            insert a;

            upsert a;

            }

            else

            {

                //list<account>ac;

                system.debug('the  accounts '+ ac );

                

            }

            

            

        }

    }