• ShravanKumarBagam
  • NEWBIE
  • 50 Points
  • Member since 2012

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 58
    Questions
  • 17
    Replies

Hi,

 

   My Scenario is The primary focus of this assignment is to demonstrate a more complex user interaction. The user will select one (or more) accounts on the left, click “Show Selected Accounts” and the results will show in the right.

Class

 

My code almost ok except show method when i select an account click on “Show Selected Accounts”  it getting error..

What wrong in my code..

 

public with sharing class assignment31cls {


public List<Account> lst {get; set;}

public list<wrapper> listwrap {get; set;}

public class wrapper {

public account acc {get; set;}

public boolean check {get; set;}

public wrapper(account a){

acc=a;

check=false;

}

}


public assignment31cls(){

listwrap =new List<wrapper>();
List<Account > lstacc=[select id,name,phone from account limit 10];
for(Account a:lstacc){

listwrap.add(new wrapper(a));
}

}



public PageReference Show() {


for(wrapper w:listwrap){

if(w.check == true){

lst.add(w.acc);

}
}

return null;
}

}

 

 

 

 

 

 

 

 

 

 

VF Page

 

<apex:page controller="assignment31cls">
<apex:form >
<table width="100%">
<tr>
<td width="50%">
<apex:pageBlock >
<apex:commandButton value="Show Selected Accounts" action="{!Show}"/>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockTable value="{!listwrap}" var="w">
<apex:column headerValue="Action">
<apex:inputCheckbox value="{!w.check}" />
</apex:column>
<apex:column value="{!w.acc.name}"/>
<apex:column value="{!w.acc.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>

</td>

<td>
<apex:pageBlock >
<apex:pageBlockTable value="{!lst}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>

</td>
</tr>
</table>
</apex:form>
</apex:page>

 

 

 

 

 

Hi,

I' using page messages to display message on vf page.

 

  I want to display message as show below...

How can i achieve that

 

Message:'You Selected'+' '+a.name

 

ApexPages.Message msg=new ApexPages.Message(ApexPages.Severity.Info,'You Selected'+' '+a.name );
ApexPages.addMessage(msg);

Hi,

 

Can we make it Field as Read only to particular profile Through coding?

 

If it is possible,let me know how can we do that.

I want to show an error that already a record is made primary. 'Please uncehck primary on test11 record'

Take a number field on Account. Whnever a Contact is inserted for a particular account, number value in accoutn ahould be increamented by 1.

Hi,

       I've write a query on opportunity to see avg amount.

How can i see avg amount of opportunity.

 

Error:line 1, column 1: Illegal assignment from LIST to LIST

      

List<Opportunity> lst = [SELECT AVG(Amount) FROM Opportunity];

 

 

Hi,

 

  here is my code.Scenario is when a record is created on account object triggers then it will shoot mail.

trigger acctrig on Account (before insert) {

account a=trigger.new[0];


list<string> toaddress=new list<string>();

toaddress.add('shravankumabragam@yahoo.com');



String subject = 'Account Trigger';
String body = 'Hi, Account trigger has been fired,new account has been created.please check on Account object' ;
String Signature = 'B.Shravankumar';

Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();

mail.setToAddresses(toaddress);
mail.setSenderDisplayName('Salesforce Outbound Notification');
mail.setsubject(subject);
mail.setplaintextbody(body);
mail.setuseSignature(true);

Messaging.sendEmail(new Messaging.singleEmailmessage[]{mail});

}

Hi,

 

I have 10 BatchApex Clases ,i need execute at  a time.

       Do i need to write a apex code for 10 batch classesin developer console .

Otherwise is there any other process.

 

 

Hi,

         

     I am write a test class for batch apex,my code coverage is 33%, it is covered only start method.

 

How can i write test class for execute method?

 

 

 

Testclass for Batch Class   

 

@isTest

private class testtrainingbatchcls {

static testmethod void m1() {


 List<training__c> lst=new List<training__c>();


for(integer i=0;i<1500;i++) {
training__c t=new training__c();
t.name = 'T'+i;
lst.add(t);
 }

 trainingbatchcls obj=new trainingbatchcls();
Database.executeBatch(obj);

}

 }

 

 

Batch Apex Class

 

 

global class trainingbatchcls implements Database.batchable <sobject>{


global list<training__c> start(Database.BatchableContext bc){


List<training__c> lst=new List<training__c>();
for(integer i=0;i<1500;i++){


training__c t=new training__c();
t.name = 'T'+i;
lst.add(t);

}
return lst;
}



global void execute(Database.BatchableContext bc,list<training__C>lst) {

insert lst;

}


global void finish(Database.BatchableContext bc){

list<string> toaddress = new list<string>();
toaddress.add('shravankumarbagam@yahoo.com');


String subject = 'Batch class run complete';
String body = '';

Messaging.singleEmailMessage mail = new Messaging.singleEmailMessage();

mail.setToAddresses(toaddress);


mail.setSenderDisplayName('Salesforce Outbound Notification');
mail.setSubject(subject);
mail.setPlainTextBody(body);
mail.setUseSignature(false);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}

 

 

}

 

  I write a test method for below class code coverage is 60% can any body tell how can i write a testmethod for the delete event...


Class TestMethod

@isTest
 
 private class testparamcls{
 
 
     static testmethod void method(){
 
    paramcls obj=new paramcls();
      obj.delrec();
     
      }
      
          
 
 }



Class

  public with sharing class paramcls {

    public PageReference delrec() {
        System.debug('----------------RecordId---------------'+recordId);
        Account acc = [Select id from account where id=:recordId];
        delete acc;
        
        pagereference ref = new pagereference('/apex/param');
        ref.setredirect(true);
        return ref;
    }

    public string recordId{get; set;}
    public List<Account> lst {get; set;}
    
    public paramcls(){
    
        lst = [Select id, name, phone from Account];
    }

}