• SFDC143
  • NEWBIE
  • -3 Points
  • Member since 2013

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

Hai,

 

Am not able to pass the Id to a class constructor.Once see my constructor and its test class.This class is based on wrapper class.The test code is not covered by passing OID variable also.And also getting error on 1 method because of id is not passed.

 

Class Constructor :

 

Public structural_Class(){


  ID ids= ApexPages.currentPage().getParameters().get('oid');
try{
list<Structure__c> lststrcs=[select id,Combined_Plan_Area__c,CombinedSurfaceArea__c,Length__c,AddStructure__c,Surface_Area__c,Total_Area__c,

Width__c from Structure__c where AddStructure__c =: ids];----->onload getting records based on ids.

if(lststrcs.size()>0){
for(Structure__c s:lststrcs){
StructreMap.put(s.Id,s);
wrapper1 w1=new wrapper1();
w1.strvtreId=String.ValueOf(s.id);
w1.width=String.valueof(s.Width__c);
w1.Length=String.valueof(s.Length__c);
w1.Total_area=String.valueof(s.Total_Area__c);
w1.surface=String.valueof(s.Surface_Area__c);
CombinedPlanArea =String.valueof(s.Combined_Plan_Area__c);
CombinedSurfaceArea =String.valueof(s.CombinedSurfaceArea__c);

strc_recs.add(w1);
}
}else{
wrapper1 w1=new wrapper1();
w1.width=null;
w1.Length=null;
w1.Total_area=null;
w1.surface=null;

strc_recs.add(w1);
system.debug('values on load.12333.....');
}

}
catch(exception e){

}
show_surfce=false;
}

 

Test Class:

apexpages.currentpage().getparameters().put('ids',opp.Id);----->passing  oid  parameter,but it is not passed to constructor
structural_Class src=new structural_Class ();
structural_Class.wrapper1 rp = new structural_Class.wrapper1();
rp.length = String.valueof(sr.Length__c );
rp.width= String.valueof(sr.Width__c );
rp.Total_area = String.valueof( sr.Total_Area__c);
rp.Surface = String.valueof( sr.Surface_Area__c);
rp.strvtreId = String.valueof(sr.Id);

src.add();
src.str_num=String.valueof(2);
src.strc_recs.add(rp);
src.aiding_rows();
src.getnumbs();
src.Total_surface_area();
src.strucutureims();-------------------------Error on this Method because id is not passed on constructor.

 

Err Msg:  System.NullPointerException: Attempt to de-reference a null object

 

Method :

Public Pagereference strucutureims(){
for(wrapper1 w:strc_recs){
If(w.strvtreId == Null)
{
Structure__c s=new Structure__c();
s.Length__c= Decimal.valueOf(w.length.trim());-------->Here on wards test cls is not covered and error is on this line.
s.Surface_Area__c=Decimal.valueOf(w.surface.trim());
s.Total_Area__c=Decimal.valueOf(w.Total_area.trim());
s.Width__c=Decimal.valueOf(w.width.trim());

s.AddStructure__c=ApexPages.currentPage().getParameters().get('oid');
System.debug('***s.CombinedSurfaceArea__c**'+s.CombinedSurfaceArea__c);

srecs.add(s);
}
Else
{
If(StructreMap.get(w.strvtreId) != Null)
{
Structure__c s=StructreMap.get(w.strvtreId);
s.Length__c= Decimal.valueOf(w.length.trim());
s.Surface_Area__c=Decimal.valueOf(w.surface.trim());
s.Total_Area__c=Decimal.valueOf(w.Total_area.trim());
s.Width__c=Decimal.valueOf(w.width.trim());

s.AddStructure__c=ApexPages.currentPage().getParameters().get('oid');
System.debug('***s.CombinedSurfaceArea__c**'+s.CombinedSurfaceArea__c);

srecs.add(s);
}

}
}
if(srecs.size()>0) {
System.debug('***srecs.size()**'+srecs.size());
Upsert srecs;
}
strc_recs.Clear();
System.debug('***srecs.size()**'+srecs.size());

return new pagereference('/'+ApexPages.currentPage().getParameters().get('oid'));
}

Hai,

 

Am not able to pass the Id to a class constructor.Once see my constructor and its test class.This class is based on wrapper class.The test code is not covered by passing OID variable also.And also getting error on 1 method because of id is not passed.

 

Class Constructor :

 

Public structural_Class(){


  ID ids= ApexPages.currentPage().getParameters().get('oid');
try{
list<Structure__c> lststrcs=[select id,Combined_Plan_Area__c,CombinedSurfaceArea__c,Length__c,AddStructure__c,Surface_Area__c,Total_Area__c,

Width__c from Structure__c where AddStructure__c =: ids];----->onload getting records based on ids.

if(lststrcs.size()>0){
for(Structure__c s:lststrcs){
StructreMap.put(s.Id,s);
wrapper1 w1=new wrapper1();
w1.strvtreId=String.ValueOf(s.id);
w1.width=String.valueof(s.Width__c);
w1.Length=String.valueof(s.Length__c);
w1.Total_area=String.valueof(s.Total_Area__c);
w1.surface=String.valueof(s.Surface_Area__c);
CombinedPlanArea =String.valueof(s.Combined_Plan_Area__c);
CombinedSurfaceArea =String.valueof(s.CombinedSurfaceArea__c);

strc_recs.add(w1);
}
}else{
wrapper1 w1=new wrapper1();
w1.width=null;
w1.Length=null;
w1.Total_area=null;
w1.surface=null;

strc_recs.add(w1);
system.debug('values on load.12333.....');


}
catch(exception e){ 

}
show_surfce=false;
}

 

Test Class:

apexpages.currentpage().getparameters().put('ids',opp.Id);----->passing  oid  parameter,but it is not passed to constructor
structural_Class src=new structural_Class ();
structural_Class.wrapper1 rp = new structural_Class.wrapper1();
rp.length = String.valueof(sr.Length__c );
rp.width= String.valueof(sr.Width__c );
rp.Total_area = String.valueof( sr.Total_Area__c);
rp.Surface = String.valueof( sr.Surface_Area__c);
rp.strvtreId = String.valueof(sr.Id);

src.add();
src.str_num=String.valueof(2);
src.strc_recs.add(rp); 
src.aiding_rows();
src.getnumbs();
src.Total_surface_area();
src.strucutureims();-------------------------Error on this Method because id is not passed on constructor.

 

Err Msg:  System.NullPointerException: Attempt to de-reference a null object



Method :

Public Pagereference strucutureims(){
for(wrapper1 w:strc_recs){
If(w.strvtreId == Null)
{
Structure__c s=new Structure__c();
s.Length__c= Decimal.valueOf(w.length.trim());-------->Here on wards test cls is not covered and error is on this line.
s.Surface_Area__c=Decimal.valueOf(w.surface.trim());
s.Total_Area__c=Decimal.valueOf(w.Total_area.trim());
s.Width__c=Decimal.valueOf(w.width.trim());

s.AddStructure__c=ApexPages.currentPage().getParameters().get('oid');
System.debug('***s.CombinedSurfaceArea__c**'+s.CombinedSurfaceArea__c);

srecs.add(s); 
}
Else
{
If(StructreMap.get(w.strvtreId) != Null)
{
Structure__c s=StructreMap.get(w.strvtreId);
s.Length__c= Decimal.valueOf(w.length.trim());
s.Surface_Area__c=Decimal.valueOf(w.surface.trim());
s.Total_Area__c=Decimal.valueOf(w.Total_area.trim());
s.Width__c=Decimal.valueOf(w.width.trim());

s.AddStructure__c=ApexPages.currentPage().getParameters().get('oid');
System.debug('***s.CombinedSurfaceArea__c**'+s.CombinedSurfaceArea__c);

srecs.add(s); 
}


}
if(srecs.size()>0) { 
System.debug('***srecs.size()**'+srecs.size());
Upsert srecs; 
}
strc_recs.Clear();
System.debug('***srecs.size()**'+srecs.size());

return new pagereference('/'+ApexPages.currentPage().getParameters().get('oid'));
}

 

Pls reply ASAP

We are a team of salesforce.com consultants looking for a full time Salesforce Administrator/Consultant who can work virtually with our clients from their home office.  This person must have the ability to get on a call with a client and develop a quick understanding of client business issues.  You will need to be able to evaluate a business issue faced by the customer and determine how best to employ salesforce.com to solve it. 

 

Core skills would include:

  • All normal salesforce.com administration tasks and an understanding of all major functional areas of Salesforce.com
  • Including (but not limited to) reports and dashboards.
  • Data imports (using data loader or other tools).
  • General problem solving skills in Salesforce.com
  • Have a very good feel for where visualforce can be used to solve business problems - for example, where a trigger might be used due to workflow limitations, or where a visualforce page might be used in place of the standard user interface to make a complex business task easier for a user.
  • Ability to design the data model to support given business requirements and architect the various associated systems. 
  • You should be able to efficiently, effectively, and clearly coordinate and manage work with our development team while managing the client relationship from start to finish.  This would include some evening hours to work with our overseas developers to explain & manage project requirements.
  • Salesforce.com Certified Administrator

 You do not need to be a developer – other individuals in our company will do the actual development.