• ShravanKumarBagam
  • NEWBIE
  • 50 Points
  • Member since 2012

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

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

Hi,

 

  Unable to understand the use COUNT_DISTINCT function.Can anybody explain with an example

hi,

Is there an order of operations that workflow follow?

If it is there , how can i see the operations flow...

 

Hi,

 

Integer i;

 

Public Integer i;

 

What is the difference between above two declaration.

Hi,

 

 

Integer i;

 

Public Integer i;

 

What is the difference between above two declaration..

Hi,

 

What isthe diffrence between  Public,Private,Global,and Abstract access modifiers in salesforce?

 

 

Hi,

  

Can anybody explain what is instanceof keyword in salesforce with small example?

 

In which scenario we can use this..

 

If  we can't use private variables on visualforce pages then where we can use it ?

Hi,

 

 I have developed an application, in the application i want to implement logout funcionlaity.

if  i use "/secur/logout.jsp" it will logout from salesforce...

 

i want to logout particular applilcation not from them salesforce...

 

 

Hi,

      In a vf page i'm displayed two pageblocks,

  

    

In 1st pageblock - Account records are displayed

In 2nd pageblcok-Contact records are displayed.

 

when i click on a export link on vf page, i want export the Only account records in an excel sheet ...

 

 

 

 

 

 

Hi,

         

     I've created page whenever click on add button two textboxes would be create.

When click on remove button textboxes would be delete. But when i delete Index [1] the textbox will deleted and when i  try to delete Index[4] below error occuring.. Error occuring only on remove method

 

My code everything is correct except below bug

 

   System.ListException: List index out of bounds: 3

Error is in expression '{!remove}' in component <apex:page> in page shravan1:day5task3

 

 

public with sharing class textboxcls {

public PageReference save() {

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

for(wrapper w:lstwrap){
lst.add(w.acc);
}
insert lst;

return null;
}


public Integer rowId{get;set;}

public PageReference remove() {

system.debug('***********************************************************'+rowId);
lstwrap.remove(rowId);

return null;
}


public PageReference add() {

lstwrap.add(new wrapper(lstwrap.size() ,new Account()));

// system.debug('****************************size*****************************'+lstwrap.size());


return null;
}


public List<wrapper> lstwrap {get; set;}

public class wrapper {

public Integer Index {get; set;}
public Account acc {get; set;}

public wrapper(Integer i, Account a){

Index =i;
acc=a;
}
}

public textboxcls(){

lstwrap=new list<wrapper>();
lstwrap.add(new wrapper(0,new Account()));


}


}

 

 

 

 

 

 

 

 

<apex:page controller="textboxcls" showHeader="true">
<apex:form >
<apex:actionFunction name="remove" action="{!remove}" reRender="out">
<apex:param value=" " assignTo="{!rowId}" name="p"/>
</apex:actionFunction>

<apex:pageBlock >
<apex:outputPanel id="out">
<table>
<tr>
<td>Account Name</td>
<td>Phone</td>
</tr>
<apex:repeat value="{!lstwrap}" var="w">
<tr>
<td>
<apex:inputText value="{!w.acc.name}"/>
</td>

<td>
<apex:inputText value="{!w.acc.phone}"/>
</td>
<td>
<apex:commandButton value="+" action="{!add}" reRender="out"/>
</td>
<td>
<apex:commandButton value="-" style="{!if(w.index == 0,'visibility:hidden','visibility:visible')}" onclick=" return remove('{!w.Index}')" reRender="out"/>
</td>
</tr>
</apex:repeat>

</table>
</apex:outputPanel>
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlock>
</apex:form>
</apex:page>

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

 

    Kindly Provide reference links for preparing opportunity management system.

 

Hi,

I want to display an error msg whenever invalid account id entered. please let me know how can i achieve it.

 

Here is code..

 

Class

 

public with sharing class asgn2cls {

public string SearchAccount {get; set;}

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

public asgn2cls(ApexPages.StandardController Controller){

}

public pagereference Search(){

try{

if (SearchAccount != '' ){

if(SearchAccount != '')

Account = [select id, name,BillingState,phone,website from Account where name=:SearchAccount ];

}

else {

ApexPages.Message msg=new ApexPages.Message(ApexPages.Severity.Warning,'Please Enter a Search String' );
ApexPages.addMessage(msg);
}

}

catch(exception e){

ApexPages.Message msg=new ApexPages.Message(ApexPages.Severity.Fatal,'No Accounts Found');
ApexPages.addmessage(msg);

}
return null;

}



}

 

 

VF Page

 

<apex:page showHeader="false" standardController="Account" extensions="asgn2cls">

<apex:form >
<apex:pageBlock id="pb">

<apex:pageBlockSection title="Search" collapsible="false" columns="3" >
<apex:outputLabel style="margin-left:190px"><b>Search</b></apex:outputLabel>
<apex:inputText value="{!SearchAccount}" />
<apex:commandButton value="Search" action="{!Search}" reRender="pb" style="margin-right:800px" />
</apex:pageBlockSection>

<apex:pageBlockSection title="Results" collapsible="false"></apex:pageBlockSection><br/><br/>
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockTable value="{!Account}" var="a">
<apex:column headerValue="Account Name" value="{!a.name}"/>
<apex:column headerValue="BillingState" value="{!a.BillingState}"/>
<apex:column headerValue="Phone" value="{!a.Phone}"/>
<apex:column headerValue="Website" value="{!a.website}"/>
</apex:pageBlockTable>
</apex:pageBlock>


</apex:form>
</apex:page>

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];
    }

}