Tech Support > Microsoft Windows > Windows CRM > Problem with CRMQuery.ExecuteQuery
Problem with CRMQuery.ExecuteQuery
Posted by Bhaskar Prasad Thamma on August 28th, 2003


Hello All,
I am using CRMQuery.Executequery object to retrieve activity records based
on selection criteria.It is being able to retrieve activities for single
field value (with 'and' operator) but when i am giving multiple field value
it is retrieving all records instead of specified records. I coded as
follows.

strQuery = "<fetch>"
strQuery += "<entity name='Activity'>"
strQuery += "<filter type='and'>"
strQuery += "<condition attribute='statecode' operator='eq' value='0'/>"
strQuery += "<condition attribute='objectname' operator='not-null'/>"
strQuery += "<condition attribute='subject' operator='not-null'/>"
strQuery += "</filter>"
strQuery += "<filter type='or'>"
strQuery += "<condition attribute='objectid' operator='eq'
value='{D4E5F144-9743-43C5-8C1D-5D28A8C6E31A}'/>"
strQuery += "<condition attribute='objectid' operator='eq'
value='{BAFD0E86-F594-4182-9402-1F169B1A4A05}'/>"
strQuery += "</filter>"
strQuery += "<attribute name='subject'/>"
strQuery += "<attribute name='activitytypecode'/>"
strQuery += "<attribute name='statecode'/>"
strQuery += "<attribute name='prioritycode'/>"
strQuery += "<attribute name='scheduledstart'/>"
strQuery += "<attribute name='activityid'/>"
strQuery += "<attribute name='objectname'/>"
strQuery += "</entity>"
strQuery += "</fetch>"

results=oQuery.ExecuteQuery(oUserAuth, strQuery)

Please suggest me the solution.