function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shreyashi Akhauri 6Shreyashi Akhauri 6 

write a SOQL to fetch the cases related to logged in users.

Relationships: User -->Service Appointments ---> Work Orders -->Cases
   
Service Appointment (Parent) - Work Order(Child) - Cases(Parent to Work order)
karthikeyan perumalkarthikeyan perumal
Hello, 

Try use this SOQL.

Bind varialbe in SOQL 
String str = 'open';

List<Case> caseList = [SELECT  Status, Origin from Case 
WHERE OwnerId=:UserInfo.getUserID() 
And Status !=:str];

For Dymnamic Query 
String str = 'open';
String userId = UserInfo.getUserID();
String queryStr = 'SELECT  Status, Origin from Case WHERE OwnerId=:userId And Status !=:str';
List<Case> caseList = Database.query(queryStr);

Hopw this will help you. 

Thanks
karthik