• My Own
  • 100 Points
  • Member since 2010

  • Chatter
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
  • 56

Hi frnds,


In this Rental_detail__c (custom object), I created a standard field (ID) with autonumber  format {0}.

Now I am inserting a record and I want the ID after insertion, so i thought of querying Max(ID).


I tried this part of code in my controller expecting it to return serial number, but is returning a random string (a0B900000022W9aEAE)


 List<AggregateResult> groupedResults = [SELECT MAX(ID)maxval FROM Rental_detail__c]; 

 String newId;

 if(groupedResults .size() > 0)            {         

      newId  =  ''+groupedResults[0].get('maxval') ;


 System.debug('New id:'+newId);


Pls help me on this.

  • July 24, 2011
  • Like
  • 0



When I click  “Calculate your organization code coverage” under Setup/Apex Classes it shows me 76%, and when I click “Run All Tests” it shows 77%. (in sandbox)


But still when I try to upload the class to production, it fails and displays “Average test coverage across all Apex Classes and Triggers is 74%, at least 75% test coverage is required.”


Does each class needs to be 75% covered or overall code coverage should match 75%?





hi all



I have written a controller for inserting bulk appointments. Actually the objective is i have created an appointment object in which i have two fields FROM and TO. I have taken these fields into another visual force page.Now user goes to that visual force page and enters the from and to timings.For ex:user want bulk appoitments from 1 o clock to 3 then in from field he enters 1 and to field he enters 3. and he will get bulk appointments from 1:00,1:10 1:20 so on upto 2:50. for this i have written the following controller

public class ExtTwo
public ExtTwo(ApexPages.StandardController controller) 
userInputAppointment = new Appointment__c();

public Appointment__c userInputAppointment {get; set;}
public list<appointment__c> apps {get;set;}  
public list<appointment__c> apps1 {get;set;}  
public list<appointment__c> apps2 {get;set;}
public list<appointment__c> apps3 {get;set;}
public list<appointment__c> apps4 {get;set;}
public list<appointment__c> apps5 {get;set;}

public PageReference save()
apps = new list<appointment__c>();
apps1 = new list<appointment__c>();
apps2 = new list<appointment__c>();
apps3 = new list<appointment__c>();
apps4 = new list<appointment__c>();
apps5 = new list<appointment__c>();
integer i=integer.valueof(userInputAppointment.from__c);          
integer i1=integer.valueof(userInputAppointment.To__c);
integer i2=integer.valueof(userInputAppointment.from_min__c);
integer i3=integer.valueof(userInputAppointment.To_Min__c);

for(integer k=0;k<(60-i2)/10;k++)
appointment__c ap = new appointment__c();
ap.branch__c =  userInputAppointment.branch__c;
ap.account__c = userInputAppointment.Account__c;
ap.appt_date__c = userInputAppointment.appt_date__c;
ap.Appt_AM_PM__c= 'AM';
ap.Appt_AM_PM__c= 'PM';
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.from__c));
ap.Appt_Hour__c =String.valueOf(integer.valueof(userInputAppointment.from__c)-12);
ap.Appt_Minute__c = userInputAppointment.from_min__c;
insert apps1[0];
and now u see i have declared userinputappointment as a value that is taken from the user . now i have written the test case li8ke this for my controller
private class extwoTestclass

static testmethod void TestController() 
Staff__c s1 = new Staff__c();
      insert s1;

Branch__c b = new Branch__c();
b.Name = 'Test';
b.Region__c = 'Market Price';
insert b;

Account a = new Account ();
a.LastName = 'Test';
a.Branch__c = b.id;
a.PersonMobilePhone = '9550412970';
insert a ;

       Appointment__c app = new Appointment__c();
        app.from_min__c = '00';
        insert app;
ApexPages.currentPage().getParameters().put('id', app.id);

        ApexPages.StandardController con = new ApexPages.StandardController(app); 
            ExtTwo cs = new ExtTwo(con);    
        pagereference s7 = cs.save();
now i am getting this error system.null pointer expression.Class.ExtTwo.save: line 24, column 27 Class.extwoTestclass.TestController: line 60, column 28 External entry point
now this error indicatres in my controller the userinputappointment.from__c and all fields are taking null values plz help me in writing the test case for my code



Hi all




I have written a controller that have null fields that user has to enter.In this case wheen i write test  case for my controller i am gettin argument cannot be null.plz help me to write test case in this kind of situatins

Hi All, 


 I am crating a new package, once the package is installed, I would like to run the post install script that should automatically add the custom List buttons to the Search Layouts for the objects(Custom/Standard). Please post any idea to accomplish this. 


An Immediate help would be greately helpful. 

  • January 03, 2013
  • Like
  • 0


Hi All,


    I would like to display "Views" in VF Page.  How to display the views in VF Page not using "ListView" and "Enhanced List".



Any help would be greatly appriceated.

  • August 23, 2011
  • Like
  • 0



Hi All, 


I need to do changes for "ViewCase" functionality  in "Self Service Portal", I didn't find any way to customize the functionality using VF. 

Any help would be greatly appreicaited.  Please have a look into this. 


When user clicks on view suggested solutions, then I need to navigate him to my own page. 






Hi All,  

   I am trying to get the list of documents based on createdDate using Dynamic SOQL.

   I am getting SOQL Exception in this.  Please see the sample code. Any help would be greatly appreciated.    


Sample Code:  

Datetime fromDate = datetime.newInstance(2005,10,08, 1,02,03); 


string sUserQuery = 'Select Name,CreatedDate From Document where CreatedDate >' + fromDate; 

system.debug('**User Query**' + sUserQuery); 

List<Sobject> lstQueryRecords = Database.query(sUserQuery); 

system.debug('--------lstQueryRecords-------' + lstQueryRecords); 


 catch(Exception ex){



Debug Logs :  System.QueryException: line 1:76 no viable alternative at character '<EOF>'

                          DEBUG|line 1:76 no viable alternative at character '<EOF>'

Hi All, 


I am new to GoogleApps integration with SF.  

    I am getting the google token from googlesites by providing the username and password from SFDC, How would I convert that  temp token(One Time user token) to a valid google&salesforce session token. So that I can use the information which was inside my googlesites with in the salesforce.


Any help would appricated. Thanks in Advance. 







  • December 28, 2011
  • Like
  • 0



Hi All, 


I have a problem with command button action, Parameters  inside a repeater which is inside a pageblockTable.

Parameter values are not getting the values which was assigned in repeater.  Its like grid inside a grid control. 


any help would be greatly appreciated. 


Thanks in advance. 

  • December 19, 2010
  • Like
  • 0

I am trying to create a dynamic data table based on the query result of a partial value entered in an input field. This part worked great. The part that I am having problems with is, when the user clicks on a row in the data table, the value in the input field should be re-populate with the value from the selected row in the data table.

However, the field population only works on the first click, and then it stops working for subsequent clicks. I have been pulling my hair out trying to figure why. I'm also gotten sporadic results such as clicks on only the first and last rows worked, or clicks on the first rowonly works, etc, but never on every row


Any help would be greatly appreciated.  


Thanks in Advance,

  • December 09, 2010
  • Like
  • 0



 Hi All, 


How To Identify a List Item is exist or not  in a list?. Please don't suggest me Map/Set. 


 Thanks in Advance.

  • December 06, 2010
  • Like
  • 0


Hi All,


I was trying to do "Merge Contact" Process, My current execution is allows only 100 merge operations at a time, but What I require is to process more that 100 merge contacts in a single process.  


Is it possible to do bulk merge process, if so please provide better solution.


Thanks in Advance.   


My Sample Code :


 public string contactMerge(List<Contact> masterContact)
                for(integer i=1;i<masterContact.size();i+=2)
                       if (i == masterContact.size()-1)
                         merge masterContact[0] new Contact[] {masterContact[i]};
                          merge masterContact[0] new Contact[] {masterContact[i],masterContact[i+1]};
             }//eof try
             catch(Exception ex){
                        system.debug('Exception Message'+ex.getMessage());
               return 'Success';


  • September 09, 2010
  • Like
  • 0

Hi All,


Is there any possibility of setting Apex Batch Size in Batch Apex. If so where would I have to specify that and is it possible to increase the batch size to more than 200. 


Thanks in Advance, 





  • September 08, 2010
  • Like
  • 0


Hi All,


I would like to display list of views information(custom created views) for a object.  Is it possible to Query the data.

If any idea, please post the answer.  


Thanks in Advance.



  • August 05, 2010
  • Like
  • 0

We have code that does the following:


  • Queries CronTrigger to see if there’s an entry for a job with an Id we previously saved in a custom setting.
  • If there is such an entry, calls System.abortJob() to kill that job. If necessary, calls System.abortJob() twice.
  • Schedules the job to run.
  • Saves the Id of the newly-scheduled job in that custom setting


Very intermittently, when we save the Id of the newly-scheduled job in the custom setting, we get a Mixed DML error:  First exception on row 0 with id a0E3000000Gj95IEAR; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): OurPkg__Settings__c, original object: CronJobDetail: []


The Id (a0E3000000Gj95IEAR) refers to the record for the custom setting.


We’re not (of course) touching CronJobDetail directly, and don’t know why we’d get a Mixed DML error for what should be a relatively innocent piece of code, or why the error happens only intermittently. To be clear, we are not doing any direct DML operations on any setup objects -- the closest we come to that is scheduling and aborting jobs.


Any thoughts on why we're getting this error, especially only intermittently, and on what we can do to get around it?



Hi All 



this is my code 

public class pay
 public void transefer()
 Http h = new Http();
 HttpRequest req = new HttpRequest();
 //String url1 = 'https://api-3t.sandbox.paypal.com/2.0/';
 String url='https://svcs.sandbox.paypal.com/AdaptivePayments/Pay ';
 string un='radhik_1310032695_biz_api1.dskvap.com';
 //string un='radhik_1311331870_per@dskvap.com';
 //string pw='311331850';
 string pw='1310032746';
   string sig ='ALIeMNX23qxDxiFSuqGvrVD7fZmrAiLQwRfHOZzphVWLml57Bz8XsGA5';

 string body='<?xml version="1.0" encoding="utf-8" ?>';
body+='<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">';
 body+='<SOAP-ENV:Header><RequesterCredentials xmlns="urn:ebay:api:PayPalAPI">';
body+='<Credentials xmlns="urn:ebay:apis:eBLBaseComponents">';
body+='<SOAP-ENV:Body><PayRequest xmlns="http://svcs.paypal.com/types/ap">';
 body+='<actionType xmlns="">PAY</actionType>';
 body+='<requestEnvelope xmlns=""><errorLanguage>en_US</errorLanguage></requestEnvelope>';
 body+='<cancelUrl xmlns="">http://www.xchaos.co.uk</cancelUrl>';
body+='<currencyCode xmlns="">USD</currencyCode><feesPayer xmlns="">EACHRECEIVER</feesPayer>';
 body+='<receiverList xmlns=""> <receiver><amount>100</amount><email>radhik_1311331396_biz@dskvap.com</email></receiver></receiverList>';
  body+=' <ipnNotificationUrl>http://www.xchaos.co.uk</ipnNotificationUrl>';
     // body+='<trackingId>1234</trackingId>';
      body+='<returnUrl xmlns="">http://www.xchaos.co.uk</returnUrl>';
  req.setHeader('Content-length', '1753' );
  req.setHeader('Content-Type', 'text/xml;charset=UTF-8'); 
  HttpResponse res =h.send(req);
  String xml = res.getBody();

 But am getting error authorization failed username and password invalid.


whats the problem in my code.


thank you in advance.


Hi All,


I am building some test code for some apex i created. When I have packaged everything up and deploying to another org i am getting an error as two of the fields i am referencing in the test code (TS_email__C and First_name__c) are being deployed as part of the package so they are not yet in the clients org.


Any help would be greatly appreciated



public static testMethod void tester()
        User currentUserTest = [Select TS_email__c, First_name__c from User where username = :UserInfo.getUserName() limit 1];       




I used to switch login for Data Loader in DEV as well as QA for any testing. And I never forget to provide Proxy settings value while switch to DEV environment and QA doesn't required it.


Today I got the below error while login into DEV environment and I had received this error before but it was fixed after some changes in Proxy settings.


"Failed to send request to https://test.salesforce.com//services/Soap/u/19.0"


Can anyone please help me to resolve this issue?




  • August 03, 2011
  • Like
  • 0

Hi frnds,


In this Rental_detail__c (custom object), I created a standard field (ID) with autonumber  format {0}.

Now I am inserting a record and I want the ID after insertion, so i thought of querying Max(ID).


I tried this part of code in my controller expecting it to return serial number, but is returning a random string (a0B900000022W9aEAE)


 List<AggregateResult> groupedResults = [SELECT MAX(ID)maxval FROM Rental_detail__c]; 

 String newId;

 if(groupedResults .size() > 0)            {         

      newId  =  ''+groupedResults[0].get('maxval') ;


 System.debug('New id:'+newId);


Pls help me on this.

  • July 24, 2011
  • Like
  • 0
How can i cover the code:
public with sharing class chkboxcon {
    public String lstwrapper { get; set; }
    public chkboxcon() {
    public chkboxcon(ApexPages.StandardController controller) {
    public boolean[] chk1{get;set;}
    public boolean[] chk2{get;set;}
    public List<boolean> chk1select=new List<boolean>();
    public List<boolean> chk2select=new List<boolean>();
    public void processdata()
        system.debug('**** One****');
        for(Integer i=0;i<lstchk.size();i++)
            system.debug('**** Two ****');
                system.debug('**These checkboxes are checked****'+i);
    public List<Chkbox__c> lstchk=new List<Chkbox__c>();
    public List<Chkbox__c> getRecs() {
        lstchk=[select Id,name from Chkbox__c];
        return lstchk;
    static testmethod void testm1()
        chkboxcon clsobj=new chkboxcon();
        ApexPages.StandardController constructorvar;
        chkboxcon clsobj1=new chkboxcon(constructorvar);
How can i cover these lines in my class.

cannot deploy this trigger:


Average test coverage across all Apex Classes and Triggers is 67%, at least 75% test coverage is required.


but before inserting this trigger when I go to Apex Classes and click on "run all tests" I got:


Code Coverage Total %85




the trigger I would like to deploy and I cannot is:

trigger UpdateCountry on Account (after insert, after update) {
        Account Acnt = Trigger.new[0];
        Account account = [Select id, Calle_envio__c, Ciudad_envio__c, Codigo_Postal_envio__c, Pais_envio__c, Estado_Provincia_envio__c,
                            Calle_facturacion__c, Ciudad_Facturacion__c, Codigo_Postal_facturacion__c, Pais_facturacion__c, Estado_Provincia_facturacion__c from Account where id =:Acnt.Id];
        if(Acnt != null && Acnt.Copiar_datos_facturacion__c == true&& (account.Calle_envio__c == null || account.Ciudad_envio__c == null || account.Codigo_Postal_envio__c == null || account.Pais_envio__c == null || account.Estado_Provincia_envio__c == null)){
                account.Calle_envio__c = Acnt.Calle_facturacion__c;
                account.Ciudad_envio__c = Acnt.Ciudad_Facturacion__c;
                account.Codigo_Postal_envio__c = Acnt.Codigo_Postal_facturacion__c;
                account.Pais_envio__c = Acnt.Pais_facturacion__c;
                account.Estado_Provincia_envio__c = Acnt.Estado_Provincia_facturacion__c;
        update account;
        Account Acnt = Trigger.new[0];
        Account account = [Select id, Calle_envio__c, Ciudad_envio__c, Codigo_Postal_envio__c, Pais_envio__c, Estado_Provincia_envio__c,Copiar_datos_facturacion__c,
                            Calle_facturacion__c, Ciudad_Facturacion__c, Codigo_Postal_facturacion__c, Pais_facturacion__c, Estado_Provincia_facturacion__c from Account where id =:Acnt.Id];
            if(account != null && Acnt.Copiar_datos_facturacion__c == true && (account.Calle_envio__c == null || account.Ciudad_envio__c == null || account.Codigo_Postal_envio__c == null || account.Pais_envio__c == null || account.Estado_Provincia_envio__c == null)){
                account.Calle_envio__c = account.Calle_facturacion__c;
                account.Ciudad_envio__c = account.Ciudad_Facturacion__c;
                account.Codigo_Postal_envio__c = account.Codigo_Postal_facturacion__c;
                account.Pais_envio__c = account.Pais_facturacion__c;
                account.Estado_Provincia_envio__c = account.Estado_Provincia_facturacion__c;
                update account;


the code coverage of 85% includes a test class I have succsefully deployed for the previous trigger


Test Class	All Tests
Tests Run	5
Test Failures	0
Code Coverage Total %	85
Total Time (ms)	1009.0

 this test class is include in the list of 5


private class TestTriggerUpdateAccountaddress
        public static testmethod void testTriggerUpdateAccount()
 Pa_s__c pais = new Pa_s__c(Name = 'TestPais');
 //assign all required values if any
 insert pais;
Provincia__c estado = new Provincia__c(Name='TestEstado');
//assign all required values if any
insert estado;
Account acc = new Account();

//Fill all mandatory fields 
acc.Name ='Test';
acc.Origen__c = 'Fitur' ;
acc.Equipo__c = 'Hoteles' ;
acc.Estado__c = 'Activo' ;
acc.Ciudad_envio__c = 'Test' ;
acc.Calle_envio__c = 'Fitur' ;
acc.Codigo_Postal_envio__c = '5454545' ;
acc.Pais_envio__c = pais.id;
acc.Estado_Provincia_envio__c = estado.id;
acc.Tipo_Publicidad__c = 'Proveedores' ;

insert acc;



But seems not enough!!! Because when I am trying to deploy the trigger I got the error-: 


 Average test coverage across all Apex Classes and Triggers is 67%, at least 75% test coverage is required.


Before deploying saids 85%, and when i tried to deply the trigger  67%??????


Please can you help me to write one more class to reach the 75% of cove  limitation to deply this trigger onto production!!






   How Quote like form can be developed . My requirement is Quote Detail & Quote Lines Sections . Pls help.




HI,while installing the package, getting this error as follows

"The requested package does not exist or has been deleted. Please contact the package publisher for assistance. If this is a recently uploaded package, please try again soon". Kindly let me know asap.

global void ConstructExclustionCriteria(string ProductName,String City)
DripExclusionConditions__c exclustionCriteria=DripExclusionConditions__c.getInstance(ProductName.toLowerCase());
exclustionQuery= ' Where Product_Offering_Type__c=:mProductName and IsConverted = false and DP_WriteOff__c !=:LeadWrittenOff and OGL_Positive__c=false and Status not in:LeadOfferingStatus and Lead_Vaildity__c not in:LeadValidity and Last_know_Status__c not in:LeadLastKnownStatus and Main_Status_Code_F__c not in:MainStatusCodeF and Quality_Check__c not in : QualityCheck ';
LeadRefereneExclustionQuery=' Where Lead__r.Product_Offering_Type__c=:mProductName and Lead__r.IsConverted = false and Lead__r.DP_WriteOff__c !=:LeadWrittenOff and Lead__r.OGL_Positive__c=false and Lead__r.Status not in:LeadOfferingStatus and Lead__r.Lead_Vaildity__c not in:LeadValidity and Lead__r.Last_know_Status__c not in:LeadLastKnownStatus and Lead__r.Main_Status_Code_F__c not in:MainStatusCodeF and Lead__r.Quality_Check__c not in : QualityCheck ';
public String MonthlySchedulingQuery
strDependentAction.add('Wrong Number');
cluster.add('NO NUMBER');

MainQuery='Select Id, Name, Lead_City__c, Lead_Cluster__c, Lead_Priority__c, Mailer_Mode__c, MobilePhone, Email, HasOptedOutOfEmail, HasOptedOutOfFax, Product_Offering_Type__c, Non_Connects__c, IsConverted, Exclude_All__c, Loan_Amount1_offer__c, Main_Status_Code__c, Dependent_Action__c, Total_SMS_failed__c, Total_SMS_sent__c,TOTAL_RPC_R__c,Total_Not_interested_Count__c,LeadSource From Lead ';
MainQuery += exclustionQuery;
MainQuery += ' and (IsInDripCampaign__c=0 or IsInDripCampaign__c=null) and Lead_City__c=:CityName ' ;
MainQuery += ' and ( ';
MainQuery += ' Lead_Cluster__c in:cluster ';
MainQuery += ' OR ';
MainQuery +='(( Non_Connects__c > 25 OR (Non_Connects__c > 10 AND Total_SMS_failed__c >= 5) OR (Main_Status_Code__c=:strDispositionStatus or Dialer_Status__c in:dialerStatusMonthly)) AND Last_RPC_date__c=null) ';
MainQuery +=' OR ';
MainQuery+=' Dependent_Action__c in:strDependentAction ';
MainQuery+=' )';
(Lead_Cluster__c in:cluster) OR (Non_Connects__c > 25 or (Non_Connects__c > 10 AND Total_SMS_failed__c >= 5) OR (Main_Status_Code__c=:strDispositionStatus) ) ';

MainQuery += ' and ((Lead_Cluster__c in:cluster) OR(( Non_Connects__c > 25 or (Non_Connects__c > 10 AND Total_SMS_failed__c >= 5) or (Main_Status_Code__c=:strDispositionStatus or Dialer_Status__c in:dialerStatusMonthly)) and Last_RPC_date__c=null))' ;
MainQuery += ' or Dependent_Action__c in:strDependentAction) ';
//MainQuery += ' and IsInDripCampaign__c=0 and Lead_City__c=:CityName and (Lead_Cluster__c in:cluster ) ';
MainQuery+= OrderByClause ;
MainQuery+= ' limit 200' ;
return MainQuery;
While Ruuning Test, Error is generating ....please Check above code
Error Message: System.NullPointerException: Attempt to de-reference a null object

Stack Trace: Class.DripCampaignSchedulerQueryClass.ConstructExclustionCriteria: line 33, column 28 Class.DripCampaignSchedulerQueryClass.testDripCampaignSchedulerQueryClass: line 264, column 9 External entry point

Code Coverage: 25%

Very thankful if anybody help




I have an after update trigger.


The value of formula fields is null. If I query the database again, it shows the values. My formula fields have a reference to lookup field - i.e if my object X has a reference to Object Y, the formula field on X is referencing Y__r.Visits__c


I don't see this documented anywhere...


hi i have wriiten a code which contains 6 insert statements it is working fine for me in sandbox but when we are doing migration its failing and giving too many script statements please help me resolve this issue



I got the following Error when I am installing the Error,

Your requested install failed. Please try this again.

None of the data or setup information in your salesforce.com organization should have been affected by this error.

If this error persists, contact salesforce.com Support through your normal channels and reference number: 303507728-8133 (1463461592)


When this Error occurs ,if any one know about this,Please tell me.






We have a package that uses Custom Settings (protected).  The visualforce pages/classes in the package can access it fine, without problems, but the FLEX app we have in the package cannot access it.


Does anyone have any suggestions or advice how to let the Flex app reach the custom settings without making new ones?