• Michael Dsoza
  • NEWBIE
  • 290 Points
  • Member since 2011
  • Consultant
  • Cognizant Technology India Pvt Ltd

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 77
    Questions
  • 118
    Replies
Hello All,
I am trying to create an action of type "Post to Chatter" but whenever I go to select "User Id" from lookup then I don't see any Id value there. 
I see recusion there as it always show me reference value & I am not able to select any user Id (OwnerId, CreatedById etc.).

It seems like BUG & do let me know if everyone is facing the same issue OR any workaround to resolve this.
First
SecondThird
Hi,

We have implemented one solution using Master Detail Relationship. While submitting Master Record for an approval, we create it's detail records. It's functionality is working fine as per requirement but while writing its test classes, we are getting "ENTITY_IS_LOCKED, the entity is locked for editing: [] -- Insert Failed".

We are running test method using business user who actually creates master record & its detail records gets automatically created as per business logic.

As I understand, Master record gets automatically locked when submitted for an approval & hence detail object also gets locked (Controlled by Parent sharing setting). That's why while creating record for detail object, we are getting "ENTITY_IS_LOCKED, the entity is locked for editing: [] -- Insert Failed".

Also, Why am I not getting this error while testing actual implementation ??

Kindly let me know how can we fix this test class issues. 

Thanks.
Michael Dsoza
Hi,
As having past java experience, we usually create separate file for CONSTANTS & their VALUES. Since we have "CUSTOM LABELS" in Salesforce to get String KEY & VALUE but we don't want these CONSTANTS to be change in future from SETUP. Also, Hard-Coding values are always bad practice and we have kept all this CONSTANTS in separate global class named "Global_Constants" where each constants is marked with static, final & assigned with value. 
Also, I had created getter method to access this static constant variable but whenever we try to access this, we receive error message as "variable_name does not exist". 
Can you please let us know, How can we create global page class like $User, $Label in Apex ?? OR
How can we access these CONSTANTS on VFPage without using these class as "Controller / Extensions" (Since I want to make it separate, global & to be accessible in every page)

Thanks.
I am trying to get back a count of records in the task / event object for contacts so that I can update a contact field with the correct vale of activity.

I am passing a LIST<ID> to the function. The trouble appears on the highlighted lines below
LIST<TASK> objTasks = [SELECT WHOID, count(ID) FROM TASK WHERE WHOID IN :ContactIDs];
LIST<EVENT> objEvents = [SELECT WHOID, count(ID) FROM EVENT WHERE WHOID IN :ContactIDs];

The Error I get is:
Field must be grouped or aggregated: WhoId

But if I try and group it, it gives me errors as well
LIST<TASK> objTasks = [SELECT WHOID, count(ID) FROM TASK WHERE WHOID IN :ContactIDs GROUP BY WHOID];
LIST<EVENT> objEvents = [SELECT WHOID, count(ID) FROM EVENT WHERE WHOID IN :ContactIDs GROUP BY WHOID];
This gives the error
Illegal assignment from List<AggregateResult> to List<Task>


 

The Function
PUBLIC VOID updateActivityCount( LIST<ID> listContacts )
	{
        LIST<ID> ContactIDs = NEW LIST<ID>();
		ContactIDs = listContacts;

		INTEGER tmpTasks = 0;
		INTEGER tmpEvents = 0;

		
		LIST<CONTACT> contactUpdate = NEW LIST<CONTACT>();
		MAP<ID, INTEGER> contactTasks = NEW MAP<ID, INTEGER>();
		MAP<ID, INTEGER> contactEvents = NEW MAP<ID, INTEGER>();

        LIST<TASK> objTasks = [SELECT WHOID, count(ID) FROM TASK WHERE WHOID IN :ContactIDs];
        LIST<EVENT> objEvents = [SELECT WHOID, count(ID) FROM EVENT WHERE WHOID IN :ContactIDs];

		FOR(TASK thisTask : objTasks)
		{	contactTasks.put(thisTask[0], thisTask[1]);	}

		FOR(EVENT thisEvent : objEvents)
		{	contactEvents.put(thisEvent[0], thisEvent[1]);	}

		LIST<CONTACT> objContacts = [SELECT ID FROM Contact WHERE ID IN :ContactIDs];
		FOR(CONTACT thisContact : objContacts)
		{
			IF( contactTasks.containsKey( thisContact.Id ) )
			{	tmpTasks = contactTasks.get( thisContact.Id );	}
			ELSE
			{	tmpTasks = 0;	}

			IF( contactEvents.containsKey( thisContact.Id ) )
			{	tmpTasks = contactEvents.get( thisContact.Id );	}
			ELSE
			{	tmpEvents = 0;	}

			thisContact.activity_this_cfy__c = tmpTasks + tmpEvents;
			contactUpdate.add( thisContact );
		}

		//--    Execute the update for contactUpdate
		//------------------------------------------------------------------------------------------------------------------------------
		if ( !contactUpdate.isEmpty() )
		{
			TRY{ update contactUpdate; }
			CATCH ( Exception ex )
			{   SYSTEM.DEBUG(thisPage + 'Could not update Contact. Cause: ' + ex.getCause() );  }
		}
	}	//--	END updateActivityCount


 
Hallo all together,

I am new to APEX. I am just writing a trigger that uses the date (DaysBetween) method. The trigger shall run after insert of a new record or update of an existing record. In my understanding I should use here "after insert, before update". However, the part when the record is updated (before update) does not work correctly when the date field is updated. The date.daysbetween method does not count according to the new date value but still calculates with the old date value. When I change the to "after update" the trigger works fine. But is this correctlike this? I believe for record updates I shold use "before update" as I have already the record Id.

Here is my code:
 
trigger updatePressesTrigger on Press__c (after insert, before update) {

    List <Press__c> presses = [Select Id, Production_Start_Date__c,Survey_6_Mth_After_Handover__c From Press__c Where Survey_6_Mth_After_Handover__c = False AND Production_Start_Date__c !=Null AND RecordTypeId ='01220000000YE4U' AND (Production_start_status__c = 'F' OR Production_start_status__c = 'I')];
    
    
    If(presses.size() >0){
    List <Press__c> pressesToUpdate = new List<Press__c>();
    
    
    //Determine Presses where Production Start Date > 6 month
    For(Press__c press : presses){
        date prodStartDate = press.production_start_date__c;
        date todayDate = date.today();
        
        integer daysDifference = prodStartDate.daysBetween(todayDate);
        if(daysDifference > 180){
            press.Survey_6_Mth_After_Handover__c = True;
            pressesToUpdate.add(press);
        }
        update pressesToUpdate;
    }
  }
}

And here is the Test Class:
 
@isTest
public class testUpdatePressesTrigger {
    static testMethod void testUpdatePressTrigger(){
        
        //Create Account
        Account a = new Account();
        a.name = 'Prospecta';
        a.recordtypeid = '01220000000YE4P';
        a.Market_segments__c = 'Industrial Printer';
        insert a;
        
        
        //Create Press
        Press__c p = new Press__c();
        p.Name = 'RA105';
        p.RecordTypeId = '01220000000YE4U';
        p.Year__c = '2015';
        p.Survey_6_Mth_After_Handover__c = False;
        p.Production_start_date__c = Date.newInstance(2016,5,1);
        p.Account__c = a.Id;
        p.Production_start_status__c = 'F';
        insert p;
        
        
        //Update press
        p.Production_start_date__c = p.Production_start_date__c - 200;
        update p;    
        
    }
}



Thanks for your advice!
Hi

I have some records listing on visualforce page . I want to filter these records based on selected value of custom picklist. I am not able to get selected value of this picklist in apex class.

My visualforce page is:
 
<apex:page standardController="Line_Item__c" extensions="LineItemPackagesExtensions" recordSetVar="lineitems" >
	<apex:pageBlock title="Search for Packages">
        	<apex:outputLabel >Packages Category</apex:outputLabel>
		<apex:inputField value="{!prdcat.Product_Category__c}" >
                	<apex:actionSupport event="onchange" rerender="packagesList" action="{!filterPackages}"/>
		</apex:inputField>
            	<apex:outputPanel id="packagesList">
                	<apex:pageBlockTable value="{!Packages}" var="a">
                    		<apex:column value="{!a.Name}"/>
                    		<apex:column value="{!a.Product_Category__c}"/>
                    		<apex:column value="{!a.Cost__c}"/>
                    		<apex:column value="{!a.Stay__c}"/>
                    		<apex:column value="{!a.Activity__c}"/>
                    		<apex:column value="{!a.Description__c}"/>
                	</apex:pageBlockTable>
           	</apex:outputPanel>
        </apex:pageBlock>
</apex:page>

Apex class is:
 
public class LineItemPackagesExtensions {

    public Package__c pkgs;
    public List<Package__c> Packages { get; set; }
    public Package__c prdcat{get;set;}
    


    public LineItemPackagesExtensions(ApexPages.StandardSetController controller) {
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
    }

    public List<Package__c> getPackages(){
        Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c ];
        return Packages;
    }
    
    public void filterPackages() {
    	Packages = [SELECT Name,Product_Category__c,Cost__c,Stay__c,Activity__c,Description__c FROM Package__c 
           where Product_Category__c=:prdcat.Product_Category__c ];
    }

}

When I change the value of picklist it throws the following error

Attempt to de-reference a null object
Error is in expression '{!filterPackages}' in page addopportunitylineitem1: Class.LineItemPackagesExtensions.filterPackages: line 35, column 1


Please help to achieve this.
Thanks
Rohitash
Hello all,
 I'm trying to retrieve the latest attachment from Job_Applicants__c and the latest attachment from from Applied_Applicants__c and combine into a single blocktable row. The requirement i'm trying to achieve is that a job applicant can attach a resume to their account record but they need to attach a customized cover letter for each job they apply to. So far i'm just tampering around with soql code so any suggestions are very much appreciated.

  Records = [Select Name,First_Name__c,Last_Name__c, (Select Id, LastModifiedDate From Attachments Order By LastModifiedDate DESC)
                 From Job_Applicants__c t where Id in (select Applicant__c from Applied_Applicants__c where JobPosting__c=:A and Status__c not in    ('Offered','Taken'))];

   Applicants =[Select Id, (Select Id, LastModifiedDate From Attachments Order By LastModifiedDate DESC)
                   from Applied_Applicants__c where JobPosting__c=:A and Status__c not in ('Offered','Taken')];
whats is the use of {}, [] these to use in soql query, is there any specific use to use ?

can you pls explaine me with query exampls.


thanks in advance. 
Hi,
I am trying to login to the sandbox, and I am prompted to enter the verification code but the email seems to have sent to a different email (*******@****le.com) than the email (*******@****nk.com) I have in Salesforce personal information. The verification email was sent to the correct email when I login to the Salesforce.com account the first time. I have verified my email in the personal information page. Any idea what is going wrong? I can't access the sandbox without the verification code. Thanks!
Hi I'm new to Salesforce
In the follwing code, how can I avoid using the con List.
Is there a way in which you can use SOQL query on trigger.new directly instead of bringing in another List ??
trigger ContactTest on Contact (before insert, before update) {

    List<Contact> con = [Select Id, Account.Phone from Contact where Id in : trigger.new];
    for(Contact c: trigger.new)
    {

         for(Integer i=0; i< trigger.new.size() ; i++)
    {
        c.OtherPhone = con[i].Account.Phone;
    }
}

}

Also, can the above update be done with WOrkflow Rules ??

Thanks,
Murthy
Hi, 
I have one trigger (before update) & its test class. When I run its test class from Apex Test Execution (In Production) then I get trigger code coverage as 70%. But when I try to deploy the same trigger with its test class (same as Production) from UAT to Production then all test method passes but I get code coverage as 0%.
Is their anything in settings which restrict us to count code coverage while deploying ??
 
If one of my requests is for a threshold dollar amount it needs to be seen by an upper manager. However, the manager is not needed to "Approve" the request. The manager is only needed to "acknowledge" that he has seen it. Since the manager is not always available he does not want his interaction to be required and would like the approval process to continue without him. 

What would be the best way to handle this ? I'm thinking of different scenarios which would require different levels of approval and what not, but I think I may be overlooking an easier solution. 

Any help would be appreciated.
I'm looking to expand on the "relationship" function to connect contacts, and it doesn't appear to be possible with leads, only with contacts associated with an account. Is there a way to do this? I feel like this function would be far more useful for prospecting leads.
I have a workflow rule to send an email reminder. I need a rule criteria with a formula that evaluates if a date field is empty or not, in order to send the email. If the field date is empty, send the email.

Using the rule criteria builder, the rule is supposed to run if the formula evaluates to true, but I tried many formulas with no luck. Examples of what I tried are:
c4g_Contact__r.c4g_Primary_Enrollment__r.c4g_Actual_Discharge_Date__c  =  NULL
ISBLANK(  c4g_Contact__r.Primary_Enrollment_Discharged_Date__c   )
ISBLANK(  c4g_Contact__r.Primary_Enrollment_Discharged_Date__c   ) = TRUE

Any idea what I could be missing here? Thanks for any help.


User-added image

 
Hello team, 

I am developing a merging app but I cannot find to way to merge what I need. A have a multiple selection for all the accounts I want to merge and the Master Account. 
Here is the code: 
 
public class MyAccountListCntrlr {
    // PROPERTIES
    public List<AccountWrapperCls> acctList {get;set;}
    public Set<String> selAccountNames {get;set;}
    public Boolean hasSelAcct {get;set;}
    public static List<Account> accts;
    
    //	MESSAGE
    public static  Boolean showMessage {get;set;}
	public static String message {get;set;}
    
    public static List<Account> acct;//Account 1
    public static List<Account> acct2;//Account 2
    
    
    public static String sAccount{set;get;}//Selection of the Master Account
    //See the method getItems
    
    
     // CONSTRUCTOR
     public MyAccountListCntrlr(){
          acctList = new List<AccountWrapperCls>();
          selAccountNames = new Set<String>();
         showMessage = false;
          for(Account a : [SELECT AccountNumber, CreatedDate, name, id, phone, fax, website, type, industry, description, NumberOfEmployees, BillingCity, AnnualRevenue from account
          ORDER BY Account.Name]){
               acctList.add(new AccountWrapperCls(a));
          }
     }
    
    // SELECTING MASTER
    public List<SelectOption> getItems() 
    {
        List<Account> lstAcc = [select id, name from account ORDER BY Account.Name];
        List<SelectOption> options = new List<SelectOption>();
        
        for(Account acc : lstAcc)
        {
            options.add( new SelectOption( acc.id, acc.Name));
            options.sort();
        }
        return options;
    }
    
    
    
   public Account masterAcc = new account(name = sAccount);
    
    
     // METHODS
     public void displaySelectedAccountNumbers(){
          //selAccountNames.clear();
          //masterAcc = [Select name from Account where name = :sAccount];
          hasSelAcct = false;
          for(AccountWrapperCls cWrapper : acctList){
               if(cWrapper.isSelected){
                    hasSelAcct = true;
                    selAccountNames.add(cWrapper.cAccount.name);
                   
                   	//showMessage = true;
                   	//message = 'The following error has ocurred: \n' + cWrapper.cAccount.id;
                   	//accts.add(cWrapper.cAccount);
               }
               if(selAccountNames.size() > 1)
                {
                    for(Integer i = 1; i < selAccountNames.size(); i++)
                    {
                        showMessage = true;
                        message = 'The selected accounts are: \n' + selAccountNames;
                        acct = [Select id, name, phone FROM Account where id = :selAccountNames];
                        //acct2 = [Select id, name, phone FROM Account where id = :selAccountNames ORDER BY Account.CreatedDate];
                        
						
                        message = 'The selected query is: \n' + acct;
                        if(selAccountNames.size() > 1)
                        {
                         	try
                            {	
                                //acct.get(i).description = '\nAccount Name: ' + acct.get(0).Name;
                                Database.MergeResult[] results = Database.merge(masterAcc, acct, false);
                                
                                //merge acct.get(0) acct2.get(i); 
                                //merge acct2.get(i) master.get(1);
                                //If the first Account was created first than 2nd one then do not merge
                                /*if(acct.get(0).CreatedDate < acct.get(i).CreatedDate)
                                {
                                    acct.get(0).description = '\nAccount Name: ' + acct.get(i).Name;
                                    merge acct.get(i) acct2.get(0);     
                                }
                               else
                                {
                                    acct.get(i).description = '\nAccount Name: ' + acct.get(0).Name;
                                    merge acct.get(0) acct2.get(i); 
                                }*/
                            }
                            catch(Exception e)
                            {
                                showMessage = true;
                                message = 'The following error has founded: ' + e;
                            }
                        }
                    }
                    
                    showMessage = true;
                    message = 'Congratulations, you have merge successfully your accounts, please refresh the site to see changes. ';
                }
          }
     }
    
    public PageReference PreviousPag()
    {
        return Page.LCA;
    }    
}

Can somebody help me out with this issue?
Thanks in advace. 
 
Hi ,

My user running his mobile Salesforce1 then showing this Error.

"There's a problem saving this record. You might not have permission to edit, or might have been deleted or archived."

​I also checked his profile, he is Salesforce 1 User. How can help this user to edit/ Save  via Salesforce1 on the case ?
Hi all,
I have two visualforce page and one controller in my scenario,
First page I give two input industry and product,its given the result certain group of company picture in href link.If I click one image it gives some relevent detail about the company its like  https://www.salesforce.com/customers/.


VFP-1
<apex:page sidebar="false" showheader="false" controller="sfdctest" tabStyle="account">
<apex:form >
<apex:pageMessages id="pId"/>
    <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Select a Industry & Product" >
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:selectList value="{!searchStr}" size="1"> 
                    <apex:selectOptions value="{!Industrynames}" />
          </apex:selectList>    
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <apex:selectList size="1" value="{!productName}">
            <apex:selectOptions value="{!items}"/>
    </apex:selectList> 
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <apex:outputPanel id="myRerender">

         <apex:commandButton value="Submit" action="{!soslDemo_method}"  ReRender="pgId,pId"  />
            </apex:outputPanel>

      </apex:pageBlock>
    
    <apex:pageBlock title="Customer details" id="pgId">
        
       <apex:repeat value="{!acc}" var="account">
     
             
<style>
    body {margin:50px;}
   
div.img {

    -webkit-align-items: baseline;
    align-items:baseline;
     margin: 10px;
    border: 1px solid #ccc;
    float: left;
    width: 220px;
   
    margin-bottom:25px;
    box:0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}    
  div.img:hover {
    
    border: 1px solid #777;
   
}

div.img img {
    max-width:100%;
    width: 100%;
    height: 150px;
    
}

    
div.desc {
    font-family:"arial";
    background-color : lightgrey;
    padding: 10px 20px;
   
    height: 50px;
    text-align: justify;
}   
 
    
   </style>      
 <body>
     

<div class="img" >

    <apex:outputLink target="_blank" value="{!$Page.custrefdetail}" id="tst" >   <!--   custrefdetail it is my second vfp -->
            <apex:image value="{!account.photo__c}" height="150" width="200"   /> 
        

            
     </apex:outputLink> 
    <div class="desc"><h1>
    
        {!account.Name}
        </h1>
        <p>
        {!account.Description}
        </p>
        </div>
   
</div>
    
     </body>
        </apex:repeat>
    </apex:pageBlock>
</apex:form>
</apex:page>
 
VFP: 2
<apex:page sidebar="false" showHeader="false" controller="sfdctest" action="{!hello1}" >
<apex:form >
  <apex:pageBlock >
    <apex:repeat value="{!accprd}" var="accs">
      <p>
     {!accs.Detail__c}
        </p>   

   </apex:repeat>  
        </apex:pageBlock>
     </apex:form>
  
</apex:page>

Controller

Public with sharing class sfdctest{
 Public List<Account> acc{get;set;} 
 Public List<accproducts__c> accprd{get;set;}
     public ApexPages.StandardSetController setController { get; set;}    
 public String imageURL{get;set;}
 Public String searchStr{get;set;} 
 public string productName{get;set;}

  public Void hello1(){
    accprd = New List<accproducts__c>(); 
     accprd = [SELECT Detail__c from  accproducts__c where Product__r.name =:productName  and account__c in (select ID from Account where industry=:searchStr)];
System.debug(productName);
   }

public List<selectoption> getIndustrynames()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
     options.add(new SelectOption('select','Select Industry'));     
    for (Schema.PicklistEntry a : values) 
    {                  
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options; 
}


public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('selectprd','Select Product')); 
    for(product2 c : [select ID, name  from product2  where ID IN( select Product__c from accproducts__c )]){
        options.add(new SelectOption(c.ID, c.name));
    }  
    return options;
}
    
 public  sfdctest()
  {
    acc = New List<Account>();
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
     
  Public void soslDemo_method(){
      System.debug(searchStr);
   if(searchStr.length() > 1 && searchStr != 'select'){
       acc = [SELECT Name,image__c,photo__c,Description,website from Account  where industry=:searchStr and Id in (select account__c from accproducts__c where Product__c = :productName )  ];
        System.debug('product');
       if(acc.size() == 0) {
           apexPages.addmessage(new apexpages.message(apexpages.severity.WARNING, 'Sorry, data not found'));
            return;
          }
       }

   else{
       acc = [SELECT Name,image__c,photo__c,Description,website from Account  where Id in (select account__c from accproducts__c )  ];
      
   }
  }
   }

 I try to display the hello1 method detail__c value  in my vfp2.


Thanks,
M. Sivasankari.
Hi all

I am facing one problem like i have created a vf page for record saving.when i am saving one record it is saving
but when i am saving more than one record at a time it is not saving.can any one help me..


User-added image
public class BankBookTestPage {

    public String message = System.CurrentPagereference().getParameters().get('msg');
    public List<AccountWrapper> wrappers {get; set;}
    public List<AccountWrapper> wrappers1 {get; set;}
    public List<MasterTest__c> master {get; set;}
    public List<BankBookTest__c> bankbook {get; set;}    
    public static Integer toDelIdent {get; set;}
    public static Integer addCount {get; set;}
    private Integer nextIdent=1;    
    
    public BankBookTestPage(){
        init();
    }
    
    private void init(){
        wrappers=new List<AccountWrapper>();
        Wrappers1=new List<AccountWrapper>();
        for (Integer idx=0; idx<1; idx++){
            wrappers.add(new AccountWrapper(nextIdent++));
            wrappers1.add(new AccountWrapper(nextIdent++));
                    
        }
    }
    public void delWrapper(){
        Integer toDelPos=-1;
        for (Integer idx=0; idx<wrappers.size(); idx++){
           if (wrappers[idx].ident==toDelIdent){
                toDelPos=idx;
            }
        }        
        if (-1!=toDelPos){
            wrappers.remove(toDelPos);
            
        }
        
  
  }
  
  
  
 /* public void delWrapper()
{
    Integer toDelPos = -1;
    for( Integer idx = 0; idx < wrappers.size(); idx++ )
    {
        if( wrappers[idx].ident == toDelIdent )
        {
            toDelPos = idx;
        }
    }       

    if( toDelPos != -1 )
    {
        BankBookTest__c bk = wrappers.get( toDelPos ).acc;
        wrappers.remove( toDelPos );
        
        delete bk;
    }
}*/
    

    public void addRows(){
    
    List<BankBookTest__c> accs=new List<BankBookTest__c>();
        for (AccountWrapper wrap : wrappers){
            accs.add(wrap.acc);
        }        
       // Upsert accs;
    
    
        AccountWrapper objAccWrapper;
        for (Integer idx=0; idx<addCount; idx++){
            objAccWrapper = new AccountWrapper(nextIdent++);
            if(!wrappers.isEmpty()){
                objAccWrapper.acc.BankAccount__c= wrappers[0].acc.BankAccount__c;
                objAccWrapper.acc.Date__c= wrappers[0].acc.Date__c;
                objAccWrapper.acc.Transaction_Type__c= wrappers[0].acc.Transaction_Type__c;
                
            }
            wrappers.add(objAccWrapper);
        }
    }
    public PageReference save(){
    try{
        List<BankBookTest__c> accs=new List<BankBookTest__c>();
        for (AccountWrapper wrap : wrappers){
            accs.add(wrap.acc);
        }        
        Upsert accs;
        
        //return new PageReference('/' + Schema.getGlobalDescribe().get('BankBookTest__c').getDescribe().getKeyPrefix() + '/o');
       init();
        }
        catch(Exception e)
        {  
        //ApexPages.Message myMsg = new  ApexPages.Message(ApexPages.Severity.ERROR,'Sorry...... You have entered DUPLICATE MASTER CODE' );
           // ApexPages.addMessage(myMsg); 
         
           Apexpages.addMessage(new Apexpages.message(ApexPages.Severity.Error,'Please enter the field value'));
       } 
        return null; 
  
 
 
   
    }
    
    public class AccountWrapper{
        public BankBookTest__c acc {get; private set;}
        public Integer ident {get; private set;}
        public AccountWrapper(Integer inIdent){
            ident=inIdent;
            acc=new BankBookTest__c();
        }
    }
}