Hi Forum,
Need your help regarding ActivityPary table.
Using SDK, I am querying ActivityParty table. This table has one column called "partyobjecttypecode". This column defines what kind of object the pary is in regarding field of the activity. (I. e Accont, case or any custom entity code).
When I run the simple SQL query : select * from activityparty where activityid = 'xxxxxxx',
I get the 'partyobjecttypecode' for each row. That is, if regarding object is Account then it will give me 1, if contact then 2 etc..
BUT if I use SDK (Query by Attribute) then I don't get this field even if it is in the column set.
In my business logic, I have to run code only if 'participationtypemask' is regarding and partyobjectypecode == 10002 from activityparty table but my query does not fetch the partyobjecttype code and therefor code is not going into the next statement. Please see below code with inline comments. Same is true for the ownertype field as well. Are these 2 fields from ActivityParty table are special where I cannot get them in SDK query ? if yes, then how do I check what type of object is attached to the activity Regarding field.
QueryByAttribute GetPartyQRY = new QueryByAttribute { EntityName = "activityparty", ColumnSet = new ColumnSet("activitypartyid", "activityid", "ownerid", "owneridtype", "participationtypemask", "partyobjecttypecode", "partyid") // get all these columns }; GetPartyQRY.AddAttributeValue("activityid", Activity.activityid); // activity id is passed through function EntityCollection retrievedParties = Service.RetrieveMultiple(GetPartyQRY); // Retrieve activity party recrods //Process each record to check what kind of pary it is and what type of object is to regarding field. foreach (Entity party in retrievedParties.Entities) { //participationtypemask = 8 = Regarding if(party.Contains("participationtypemask") && party.GetAttributeValue<OptionSetValue>("participationtypemask").Value == 8) { // this is to check if regarding is of whic entity type but not getting the column value itself in the query int regardingType = party.GetAttributeValue<int>("partyobjecttypecode"); if(regardingType == 10002) // custom entity { // do something but never reaches here due to the above mentioend problem } } }
Doing the same in SQL fetch me the correct result.
Any help wold be greatly appreciated to solve this mystery. We are on CRM 2011 on-premise.
Thanks for reading.
Regards,
H.Desai