• ASF
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 6
    Replies
hi,

  Can any one help me to pass the value in select option

Apex Class:

public class HousingOpportunity
{
    public Housing_Resource_Opportunity__c objHrsOpp {get; set;}
    //private String soql{get;set;}
    public HousingOpportunity()
    {
        objHrsOpp = new Housing_Resource_Opportunity__c();
   
    }
   
   public string selectBuildingname{get;set;} 

    public list<selectOption> getBuildingname()
    {
        list<selectOption> options = new list<selectOption>();
        options.add(new selectOption('','-None-'));
        list<Housing_Resource__c> houres= [Select Id,Name from Housing_Resource__c]; 
        Set<String> strUniq = new Set<String>();        
        for(Housing_Resource__c hr : houres)
        {
             if(strUniq.add(hr.Name.touppercase()))
             {
               options.add(new selectOption(hr.Name,hr.Name));
               system.debug('BuildingName--------------'+options);
             }
        }
       
        return options;
    }
 
     public string selectroomnameandnumber{get;set;}
     public List<selectOption> getroomnameandnumber()
     {
  
        List<selectOption> options = new List<selectOption>();
        options.add(new selectOption('','-None-'));
         system.debug('selectBuildingname@@@@@@@@@@@@@@@@@@@@@'+selectBuildingname);
        if(selectBuildingname != null)        // Its not covered from this line  value passing is null
        {

        String hrsSQL = 'Select Room_Name_and_Number__c from Housing_Resource__c  where Name=:selectBuildingname AND Room_Name_and_Number__c!=null';
            List<Housing_Resource__c> houres = Database.query(hrsSQL);
             //system.debug('roomnameupdown'+hrsSQL);
            for(Housing_Resource__c hr : houres)     
            {
                options.add(new selectOption(hr.Room_Name_and_Number__c,hr.Room_Name_and_Number__c ));  
            }
           
           
       } 
    
       return options;
     }
}


Test class:


@isTest
public class HousingOpportunityTestClass
{
    public static TestMethod void HousingOpportunityTestClass()
    {
         PageReference ref = Page.HousingOpportunity;
        Test.setCurrentPage(ref);
        system.debug('Test---------'+ref);

        Housing_Resource__c HousingResouce = new Housing_Resource__c(Name ='TestBuildName', Room_Name_and_Number__c = 'BN101');
        insert HousingResouce;
        
     
            ApexPages.currentPage().getParameters().put('selectBuildingname',HousingResouce.Name); 
           
            HousingOpportunity thehousopp = new HousingOpportunity();
        
      
         thehousopp.getBuildingname();
    
         thehousopp.getroomnameandnumber();

 }
 
}
  • March 21, 2014
  • Like
  • 0

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 void 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;

}
}

 

 

 

how to call the method with parameters???????????????

  • October 28, 2013
  • Like
  • 0

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?

  • October 23, 2013
  • Like
  • 0

I want auto increment number in account field. format is first four letter from account name next two digits from number. i got it but the problem i have 1000 of accounts i want the number increament upto 99 and again i want to regenerate from 1. but it goes 100, 101, 102...... 

 

       example:  UPPER(LEFT(Name, 4))+AutoId__c

 

AutoId__c  i gave display format like this   {00}. i want regenerate from 1 after it reached 99.

 

 

 

  • October 18, 2013
  • Like
  • 0

Hi, 

 

      I have a treeview in leftside. if i click  any of the link from tree view. i want to display a related records in right side.  its working properly. But the problem is after click the treeview link the page gets reload and the tree view get collapsed.  i want to reload only right side. not the whole page. Is there any possiblities are there?

  • October 16, 2013
  • Like
  • 0

Hi, 

 

 

   I want to integrate salesforce Case to Team Foundation Server(TFS). Can anyone please guide me what are the steps to follow ?

  • April 23, 2013
  • Like
  • 0

Hi, 

 

 

   I want to integrate salesforce Case to Team Foundation Server(TFS). Can anyone please guide me what are the steps to follow ?

  • April 23, 2013
  • Like
  • 0

  I want to know how to integrate the SFDC with TFS. i want to update my cases in salesforce through TFS. Right now i create a outbond message and i installed TFS server. I Don't Know Further Step. Can any one guide me??????

  • April 10, 2013
  • Like
  • 0

First i create a button in campaign and if click this button. campaign members contact and lead ownership to be changed as    campaign owner name....

 

Thi is my code can any one tell me where did i make a mistake..

 

{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}

var url = parent.location.href;

var AccId = "{!Account.Id}";
var CampId ="{!Campaign.Id}";
var CampOwnerId= "{!Campaign.OwnerId}";

var updateRecords = [];
var update_Cons = new sforce.SObject("Contact");

var result = sforce.connection.query("SELECT Id, Contact.OwnerId, Lead.OwnerId, campaignid FROM CampaignMember WHERE campaignid = '"+CampId +"'"); 
var recs = result.getArray("records");

if(confirm("Are you sure you want to update the name on related contacts and leads?") )
{
for(var i = 0; i < recs.length; i++)
{
recs[i].Contact.OwnerId= CampOwnerId;
recs[i].Lead.OwnerId= CampOwnerId;

updateRecords.push(recs[i]);
}

var result = sforce.connection.update(updateRecords);

parent.location.href = url;

if(result[0].success == 'true')
{
alert("Related contacts and leads updated successfully");
}
else
{
alert("Failed to update the related contacts and leads");
}
}

  • April 08, 2013
  • Like
  • 0

hi.

 

 Create a button in Campaign that will change the ownership of campaign members related  contacts Leads and associated Account,  

 

 

 If any one know plz help me.....................

  • April 08, 2013
  • Like
  • 0

hi

 

 First i create a button on Account. and if i click that button that related contacts owner name is changed as Account owner Name. 

 

Please give me a solution for this... 

  • April 05, 2013
  • Like
  • 0
hi,

  Can any one help me to pass the value in select option

Apex Class:

public class HousingOpportunity
{
    public Housing_Resource_Opportunity__c objHrsOpp {get; set;}
    //private String soql{get;set;}
    public HousingOpportunity()
    {
        objHrsOpp = new Housing_Resource_Opportunity__c();
   
    }
   
   public string selectBuildingname{get;set;} 

    public list<selectOption> getBuildingname()
    {
        list<selectOption> options = new list<selectOption>();
        options.add(new selectOption('','-None-'));
        list<Housing_Resource__c> houres= [Select Id,Name from Housing_Resource__c]; 
        Set<String> strUniq = new Set<String>();        
        for(Housing_Resource__c hr : houres)
        {
             if(strUniq.add(hr.Name.touppercase()))
             {
               options.add(new selectOption(hr.Name,hr.Name));
               system.debug('BuildingName--------------'+options);
             }
        }
       
        return options;
    }
 
     public string selectroomnameandnumber{get;set;}
     public List<selectOption> getroomnameandnumber()
     {
  
        List<selectOption> options = new List<selectOption>();
        options.add(new selectOption('','-None-'));
         system.debug('selectBuildingname@@@@@@@@@@@@@@@@@@@@@'+selectBuildingname);
        if(selectBuildingname != null)        // Its not covered from this line  value passing is null
        {

        String hrsSQL = 'Select Room_Name_and_Number__c from Housing_Resource__c  where Name=:selectBuildingname AND Room_Name_and_Number__c!=null';
            List<Housing_Resource__c> houres = Database.query(hrsSQL);
             //system.debug('roomnameupdown'+hrsSQL);
            for(Housing_Resource__c hr : houres)     
            {
                options.add(new selectOption(hr.Room_Name_and_Number__c,hr.Room_Name_and_Number__c ));  
            }
           
           
       } 
    
       return options;
     }
}


Test class:


@isTest
public class HousingOpportunityTestClass
{
    public static TestMethod void HousingOpportunityTestClass()
    {
         PageReference ref = Page.HousingOpportunity;
        Test.setCurrentPage(ref);
        system.debug('Test---------'+ref);

        Housing_Resource__c HousingResouce = new Housing_Resource__c(Name ='TestBuildName', Room_Name_and_Number__c = 'BN101');
        insert HousingResouce;
        
     
            ApexPages.currentPage().getParameters().put('selectBuildingname',HousingResouce.Name); 
           
            HousingOpportunity thehousopp = new HousingOpportunity();
        
      
         thehousopp.getBuildingname();
    
         thehousopp.getroomnameandnumber();

 }
 
}
  • March 21, 2014
  • Like
  • 0

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 void 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;

}
}

 

 

 

how to call the method with parameters???????????????

  • October 28, 2013
  • Like
  • 0

First i create a button in campaign and if click this button. campaign members contact and lead ownership to be changed as    campaign owner name....

 

Thi is my code can any one tell me where did i make a mistake..

 

{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}

var url = parent.location.href;

var AccId = "{!Account.Id}";
var CampId ="{!Campaign.Id}";
var CampOwnerId= "{!Campaign.OwnerId}";

var updateRecords = [];
var update_Cons = new sforce.SObject("Contact");

var result = sforce.connection.query("SELECT Id, Contact.OwnerId, Lead.OwnerId, campaignid FROM CampaignMember WHERE campaignid = '"+CampId +"'"); 
var recs = result.getArray("records");

if(confirm("Are you sure you want to update the name on related contacts and leads?") )
{
for(var i = 0; i < recs.length; i++)
{
recs[i].Contact.OwnerId= CampOwnerId;
recs[i].Lead.OwnerId= CampOwnerId;

updateRecords.push(recs[i]);
}

var result = sforce.connection.update(updateRecords);

parent.location.href = url;

if(result[0].success == 'true')
{
alert("Related contacts and leads updated successfully");
}
else
{
alert("Failed to update the related contacts and leads");
}
}

  • April 08, 2013
  • Like
  • 0

hi

 

 First i create a button on Account. and if i click that button that related contacts owner name is changed as Account owner Name. 

 

Please give me a solution for this... 

  • April 05, 2013
  • Like
  • 0