You need to sign in to do that
Don't have an account?

Parameters passing issue in methods
Hi,
i have a problem with passing a parameters. I have a static List method with parameters. i want to call that method in another method. I'm not getting the parameters value. its passing a null value.
public static List<Level2sClass> Level2List;
public static List<Level2sClass> getList2Details(Level1s__c lvl)
{
// Level1s__c lvl;
Level2List= new List<Level2sClass>();
if(ApexPages.currentPage().getParameters().get('S') == null)
{
lstLevel2 = [Select id,name,Level1_Name__c,Level1__c, (select id,account__r.name from Level2s__r where account__c =:accid ) from Level2s__c where Level1__c =:lvl.id order by id];
}else
{
lstLevel2 = [Select id,name,Level1_Name__c,Level1__c, (select id,account__r.name from Level2s__r where account__c =:accid ),(select id from Level3s__r limit 1) from Level2s__c where Level1__c =:lvl.id and id in (Select cLevel2__c from Level2__c where Account__c=:accid) order by id];
}
for(level2s__c s: lstLevel2)
{
Level2List.add(new Level2sClass(s));
}
lvl1 = lvl;
return Level2List;
}
public PageReference Save()
{
///////////// LEVEL2 /////////////////////
List<level2s__c> selectedLevel2= new List<level2s__c>();
for(Level2sClass cCon : getList2Details(Level1s__c lvl)) // here i call the method it passing a null value.
{
system.debug('@@@@@@@@@@@@@Level1@@@$$$$$$'+le1.id);
if(cCon.selected == true)
{
selectedLevel2.add(cCon.lev2);
}
}
}
Level2__c[] levl2= [Select Id from Level2__c where Account__c=: ApexPages.currentPage().getParameters().get('id')];
delete levl2;
if(selectedLevel2 != null)
{
for(level2s__c con : selectedLevel2)
{
//system.debug('CCCCCCCCCC:'+con+'\n');
string acctid =ApexPages.currentPage().getParameters().get('id');
List<Level2__c> lvl2obj= new Level2__c[0];
lvl2obj.add(new Level2__c(Name='Level2',Account__c=acctid,cLevel2__c=con.id));
insert lvl2obj;
}
}
please can anybody help me to solve this issue?
Hi,
You are passing an empty declared variable of type Level1s__c when calling a method
You'll need to popuate some data in lvl variable before you pass it as a parameter, is that information suppose to come from your visualforce page ?