locked
ActivityParty table - PartyObjectTypeCode not fetching value RRS feed

  • Question

  • 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



    • Edited by H.Desai Sunday, November 15, 2015 9:45 PM
    Sunday, November 15, 2015 9:33 PM

Answers

  • Hi All,

    Further digging helped to extract the fact that these 2 columns are available from appointment activity entity itself. Regarding field type is called 'Regardingobjecttypecode' which helps me to identify which type of object is attached.

    Just in case if some is in my situation.  Still don't know the explanation for why it appears in Sql query result but not in SDK query result. ( Probably these fields are not exposed in API)

    Regards

    H.Desai

    • Marked as answer by H.Desai Monday, November 16, 2015 4:07 AM
    Monday, November 16, 2015 4:07 AM