+ Start a Discussion
kmorf_entransformkmorf_entransform 

Testing problem

hi im having problems with a test class. everytime i run the test it gives me an error System.UnexpectedException No such column 'Name' on entity Asset__c. here is the code that givin me that error.

public static List<selectOption> manufactures(){  
   	  List<selectOption> allManufactures = new List<selectOption>();   
      Set<String> asset = new Set<String>();
      List<String> sorted = new List<String>();
     
     //query Manufacturer with no duplicates
     try{
      	for (Asset__c vAsset: [Select Name, Manufacturer__c from Asset__c] )
      	{ 
      		if (!asset.contains(vAsset.Manufacturer__c) && vAsset.Manufacturer__c != null)
      		{
      			asset.add(vAsset.Manufacturer__c);
      			sorted.add(vAsset.Manufacturer__c);
      		
      		}
      	}//end of for
     }
     catch(Exception e){
     	System.debug(e.getMessage());
     }
     
     
      //sort Manufactures in Ascending order
      sorted.sort();
      
      //add manufacturer selectOptions
      allManufactures.add(new selectOption('all','All Manufactures',false));
      for (String s:sorted)
      {
      	if (s != null)
      	allManufactures.add(new selectOption(s,s));
      	System.debug(s);
      }//end of for
      	
      
     
      return allManufactures;
   }
   

  can anyone help me?

Best Answer chosen by Admin (Salesforce Developers) 
nandurinanduri

try defining ur  class both ways and check please

 


public with sharing class urClassName {
// Code here      
}

 

 


public without sharing class  urClassName {
// Code here      
}

All Answers

nandurinanduri

hhmmm.....

Check if ur custom object Asset__c has been deployed or not.

Is your class defined as with sharing?  If so, try changing it to without sharing. 

Is your setting public (though it shouldn't make any difference outside of managed packages).

kmorf_entransformkmorf_entransform

yes the object Asset__c is in deployed. the class is not defined with sharing just public.  what does it mean when a class is defined with sharing?

kmorf_entransformkmorf_entransform

actually the asset__c is an custom field for the object auction__c, asset__c is a loopup for the object Asset__c

nandurinanduri

try defining ur  class both ways and check please

 


public with sharing class urClassName {
// Code here      
}

 

 


public without sharing class  urClassName {
// Code here      
}

This was selected as the best answer
kmorf_entransformkmorf_entransform

Yes!!!! Finally it works. thank you sir. can you explain to me what happpened. i defined my class public without sharing class and it worked