Search code examples
javascriptsalesforcesalesforce-lightningsoqlaura-framework

SOQL to query Assigned Resource fields while using WorkOrder object


I am trying to achieve following:

Select WorkOrderNumber, (Select AssignedResource.ServiceResourceId from AssignedResource), Subject,Description,Status,Job_Request_SDO__c,Job_Location__c,Job_Type__c,Job_Category__c,Job_Number_Text__c,CaseId From WorkOrder

I need ServiceResourceId value from AssignedResource and rest of the query as it is so end results would provide me everything above. Even when i directly used AssignedResource.ServiceResourceId and also appending __r to it, query is throwing error.

Can someone kindly help on this case? I above query, if i can get ServiceResourceId value I am good. I do not want to use another method and query it. Should I use wrapper class to achieve above?


Solution

  • SELECT WorkOrderNumber, 
        Subject, 
        Description, 
        Status, 
        Job_Request_SDO__c, 
        Job_Location__c, 
        Job_Type__c, 
        Job_Category__c, 
        Job_Number_Text__c, 
        CaseId,
        (SELECT AssignedResource__r.ServiceResourceId__c 
          FROM AssignedResource) 
      FROM WorkOrder
    

    That should do what you're looking for