
I need to retrieve a set of records based on a search on two different fields in two different entities. The search value can exist in either field for the record to be returned. Do I have to use FetchXML for this? I tried variations on the below for this with no luck.
jobopportunities?$select=createdon,_account_value,addcoresafety,directions,duration,jobaddress,jobtype,_list_value,name,neededemployees,positiontitle&$expand=account($select=name;$filter=contains(name, 'foo'))&$filter=contains(positiontitle, 'foo')
afaik not possible directly with a single query, you can eventually get all the records from a query where the condition is on the secondary entity (like the account name on your query) and after filter the result checking if your first condition is applied or not on your primary entity.
EDIT: thinking again, probably you will need to do a query getting all the results (so no conditions on the secondary entity, just retrieve all the records) and after check both conditions. I am talking when there is a relationship that connect both entities (like "jobpportunity" and "account" in your example query) and this relationship is bound to the records you want to retrieve (just to clarify, if you want to check accounts with your condition that are not related to jobopportunity, then you must do two separate queries)
hope it helps and sorry for the confusion.