简体   繁体   中英

How to get value of PartyList field using Javascript and oData in CRM 2011

due to CRM 2011 online problems with IE10, we have decided to convert all front-end JavaScript from Soap to oData. Everything was going fine, I installed the oData designer, centralized the queries in functions, but i ran into a problem when i tried to retrieve the partylist field Resources for ServiceActivity .

The oData query I got using the oData Query designer is the following (the guid is a sample)

ServiceAppointmentSet?$select=Resources&$filter=ActivityId eq guid'83CA6B11-6C0A-E311-8BB5-B499BAFE71A5'

but in the response i get an error that the Resources field was not found.

I tried without the select, and debugged the returned oData object, but noticed that it doesn't show both Resources and Customers partylist fields that are in ServiceActivity.

ServiceAppointmentSet?$filter=ActivityId eq guid'83CA6B11-6C0A-E311-8BB5-B499BAFE71A5'

Does anyone have any ideas?

I believe you can get the Resources and Customers by using $expand to allow the query to include the serviceappointment_activity_parties relationship. Like so:

ServiceAppointmentSet(guid'83CA6B11-6C0A-E311-8BB5-B499BAFE71A5')?
  $select=
    serviceappointment_activity_parties/ParticipationTypeMask,
    serviceappointment_activity_parties/PartyId
  &$expand=serviceappointment_activity_parties

The GUID of the activityparty is found in PartyId , and the ParticipationTypeMask integer allows you to figure out what kind of activity party it is, for example Customer is 11 and Resource is 10. The full list of ParticipationTypeMask mappings can be found here .

Issues with capitalization tend to cause alot of OData errors. Also, have you tried creating your query in LinqPad (Assuming it is not CRM-Online)? I've found it quicker in generating my OData URLs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM