• Ragz
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 7
    Replies

Hi, can someone help me write the  test method for the following custom component. I couldnt find any link to custom component test methods in the force.com knowledgebase/community. Please help.

 

public with sharing class AutoComplete_Controller{

	//Constructors
	
    public AutoComplete_Controller() {}
    
    
    public AutoComplete_Controller(ApexPages.StandardController controller) {}

	//Attributes
	
	private List<String> resultsname = new List<String>();
	private Boolean hasparams = false;
	private Boolean hasnoresults = false;
    public String state = '';
        
    //Getters and Setters
    
 	public Boolean getHasparams(){
 		return hasparams;
 	}
 	
 	public void clearValues(){
 		hasparams = false;
 	}
 	
 	public Boolean getHasnoresults(){
 		return hasnoresults;	
 	}

	public void avoidRefresh(){
	}

 	/*public void setState(String sName) {
        state = sName;
        system.debug('sName  - ' + sName);
    }
            
    public String getState() {
        return state;
    }*/
   
    public PageReference searchSuggestions() {

		//Initalize variables, hasparams just indicates that a search has started
        resultsname.clear();   
        hasparams = true;
        hasnoresults = false;

		//Obtain current parameters
        String sobjectname = System.currentPageReference().getParameters().get('objectname');
        String stext = String.escapeSingleQuotes(System.currentPageReference().getParameters().get('aname').trim())+'%';
        String stateText = String.escapeSingleQuotes(System.currentPageReference().getParameters().get('statename').trim());
        
        system.debug('State Name  - ' + state);
        system.debug('stateText - ' + stateText);
        
        //Limit Suggestions to 10 Results
        Integer iLimit = 10;
        
     //Validate if there's an input and get results
     
     if(stext.length() > 2){

		try{
	        		
			  //String sql = 'select City__C from ' + sobjectname + ' where City__C like \''+stext+'\' and State__c = ' + stateText + '' limit '+ iLimit;
			  String sql = 'select City__C from ' + sobjectname + ' where City__C like \'' + stext + '\' and State__c = \''+ stateText+'\' GROUP BY City__C'; 
			  // limit ' + iLimit;
			  //lstAR = [];
			  system.debug('SQL Formed + ' + sql );
		         	// 
		         	for(sobject x : Database.query(sql)){
		        		
		        		String s  = String.escapeSingleQuotes(((String)(x.get('City__C'))));
		        		resultsname.add(s);	
		        	}
				
				
			
		}catch(Exception e){
			
			resultsname.add('Unexpected Error, please contact support- ');	
		}


     }
       return null;
  }
  
	  
	  
	 public List<String> getResultsname(){
	  	  //Make sure to clear past values
	      clearValues();
	      if(resultsname.isEmpty()){
			hasnoresults = true;
			resultsname.add('No Results');
	      }
	      return resultsname;
	  }
}

 thank you

 

  • June 29, 2011
  • Like
  • 0

Hi Folks ,

 

I am using Auto complete functionality for lookup. It is working fine, but after selecting the searched dropdown list record value which event will fire? I used onchange function not working[if i use onpress or onclick it will not work because of i am disabling enter function through script(see below)]. Already i tried different events like onselect etc. with out using  Auto complete  Onchange function working fine . Using onchnage mehod i am getting some values from controller based on account lookup value.

 

<script>    function noenter(ev)   

{       

if (window.event && window.event.keyCode == 13 || ev.which == 13)       

{           

var ele=document.getElementById(cl);           

ele.click();           

return false;       

}       

else       

{           

return true;       

}   

}

</script>

 <apex:inputField value="{!m.Account__c}" onkeypress="return noenter(event);" onchange="test()" id="acc">                  

<c:autoCompleteController objectname="Account" additionalfield="TickerSymbol" autocomplete_textbox="{!$Component.acc}" />        

 <apex:actionFunction name="test" action="{!sample}" reRender="pb1">         

<apex:param value="{!m.Account__c}" name="ac"/>       

 </apex:actionFunction>   

 </apex:inputfield>

 

plase suggest on this..........................................................................

 

thanks 

Krish

hi! can you help me?

i have a javascript button that i made to modify the owner id if the Business_unit__c field is not null.

 

Doesnt work.. :(

 

this is the code

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

var records = {!GETRECORDIDS($ObjectType.Case)};
var newRecords = [];

for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Case");

c.id = records[n];

var efdata = sforce.connection.query("Select  Business_unit__c From case where id = " + "'" +c.id + "'" );


if(efdata == null){
alert("O caso está incompleto! Dados em falta: Business Unit");

}else{
var efdata2 = sforce.connection.query("Select  User_logged__c From case where id = " + "'" +c.id + "'" );
for (var i=0; i<efdata2.length; i++) {
c.ownerId=efdata2[i];
newRecords.push(c);



}
result = sforce.connection.update(newRecords);

window.location.reload();
}


}

Hi, can someone help me write the  test method for the following custom component. I couldnt find any link to custom component test methods in the force.com knowledgebase/community. Please help.

 

public with sharing class AutoComplete_Controller{

	//Constructors
	
    public AutoComplete_Controller() {}
    
    
    public AutoComplete_Controller(ApexPages.StandardController controller) {}

	//Attributes
	
	private List<String> resultsname = new List<String>();
	private Boolean hasparams = false;
	private Boolean hasnoresults = false;
    public String state = '';
        
    //Getters and Setters
    
 	public Boolean getHasparams(){
 		return hasparams;
 	}
 	
 	public void clearValues(){
 		hasparams = false;
 	}
 	
 	public Boolean getHasnoresults(){
 		return hasnoresults;	
 	}

	public void avoidRefresh(){
	}

 	/*public void setState(String sName) {
        state = sName;
        system.debug('sName  - ' + sName);
    }
            
    public String getState() {
        return state;
    }*/
   
    public PageReference searchSuggestions() {

		//Initalize variables, hasparams just indicates that a search has started
        resultsname.clear();   
        hasparams = true;
        hasnoresults = false;

		//Obtain current parameters
        String sobjectname = System.currentPageReference().getParameters().get('objectname');
        String stext = String.escapeSingleQuotes(System.currentPageReference().getParameters().get('aname').trim())+'%';
        String stateText = String.escapeSingleQuotes(System.currentPageReference().getParameters().get('statename').trim());
        
        system.debug('State Name  - ' + state);
        system.debug('stateText - ' + stateText);
        
        //Limit Suggestions to 10 Results
        Integer iLimit = 10;
        
     //Validate if there's an input and get results
     
     if(stext.length() > 2){

		try{
	        		
			  //String sql = 'select City__C from ' + sobjectname + ' where City__C like \''+stext+'\' and State__c = ' + stateText + '' limit '+ iLimit;
			  String sql = 'select City__C from ' + sobjectname + ' where City__C like \'' + stext + '\' and State__c = \''+ stateText+'\' GROUP BY City__C'; 
			  // limit ' + iLimit;
			  //lstAR = [];
			  system.debug('SQL Formed + ' + sql );
		         	// 
		         	for(sobject x : Database.query(sql)){
		        		
		        		String s  = String.escapeSingleQuotes(((String)(x.get('City__C'))));
		        		resultsname.add(s);	
		        	}
				
				
			
		}catch(Exception e){
			
			resultsname.add('Unexpected Error, please contact support- ');	
		}


     }
       return null;
  }
  
	  
	  
	 public List<String> getResultsname(){
	  	  //Make sure to clear past values
	      clearValues();
	      if(resultsname.isEmpty()){
			hasnoresults = true;
			resultsname.add('No Results');
	      }
	      return resultsname;
	  }
}

 thank you

 

  • June 29, 2011
  • Like
  • 0

Hi Support / PM,

 

I am working with the LeadHistory table at same place in my code,

to find the previous owner of a Lead.

 

The funny thing (and the reason of this post) is, that in my production the "oldValue" field contains/returns the ID of the previous owner and in my Sandbox it returns the Name.

 

I didn't changed the API-Version, so this should not be the problem.

 

This is my query:

 

 

		LeadHistory leadHistory = [
			SELECT Field, LeadId, OldValue, CreatedDate 
			FROM LeadHistory 
			WHERE LeadId = :leadId 
				AND Field = 'Owner'
			ORDER BY CreatedDate DESC
			NULLS LAST
			LIMIT 1
		];

 

 

and this is my Debug output:

 

 

System.debug('oldValue content: ' + leadHistory.OldValue);

 

 

Again: For production it returns ID, for Sandbox it returns Name.

 

It's not a problem for my app, as I quickly fixed it, but I wonder how this can differ between two orgs.

 

You can run the code from anonymous by putting a lead ID in the code. Of course you need field tracking on Lead Owner and at least one Owner change.

 

Thanks,

Hannes

 

 

I login to salesforce.com developer, click Setup, Build, Code and then click Generate from WSDL.  I browse to our wsdl and then get an error.
 
The error I get is "Error: Failed to parse wsdl: Unknown element: import."  Does Apex support .Net 3.0 WCF services?
 
Ryan
  • January 18, 2008
  • Like
  • 0