+ Start a Discussion
Vineet Anand 5Vineet Anand 5 

Apex Code - SOQL Issue.

Hi All,
I am working on Apex Specalist - Super Badge. I installed the required Pkg. to my org. Currently working on Automate record creation. As per Requirement need to fetch TYPE = REPAIR Or MAINTENANCE REQUEST. When query the table not finding any record having type define as Repair or Maintenance. Not sure why. Can any one guide me on same.
Rgd's
ChinnoyChinnoy
Hey Vineet,

 try this one
Type IN ('Repair', 'MAINTENANCE REQUEST');
Deepali KulshresthaDeepali Kulshrestha
Hi Vineet,

You can filter the records like this :

WHERE Type = 'REPAIR' OR Type = 'MAINTENANCE REQUEST'

Also, query the 'Type' field In the SOQL otherwise it will give you runtime error.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
Ajay K DubediAjay K Dubedi
Hi Vineet,

Use this condition helpful for you.
 
1. WHERE Type = 'REPAIR' OR Type = 'MAINTENANCE REQUEST'
2. use IN operator in soql for refer LIST or SET direct in query like

List<String> lstOfStr = new List<String>{'test1','test2'};
List<Contact> ListOfName = [SELECT FirstName, LastName FROM Contact WHERE FirstName IN : lstOfStr];

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com