Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

Retrieving RegardingObjectId and RegardingObjectTypeCode from ActivityPointer

Posted on by 10

Hi Experts,

I tried to retrieve with fetchXml the regardingobjecttypecode from the ActivityPointer Entity, but it does not return the attribute in the result.

I've tried the following fetch queries:

<fetch>

<entity name="activitypointer" >
<attribute name="regardingobjecttypecode" />
</entity>
</fetch>

or

<fetch>
<entity name="activitypointer" >
<all-attributes/>
</entity>
</fetch>

Both are not delivering the field.

When I try to retrieve the regardingobjecttypecode in a console application with the Dynamics SDK

it will also not returns the field value:

using (OrganizationServiceProxy service = new OrganizationServiceProxy(uri, null, credentials, null))
{
QueryExpression query = new QueryExpression("activitypointer");
query.ColumnSet = new ColumnSet("regardingobjectid", "regardingobjecttypecode");
EntityCollection activities = service.RetrieveMultiple(query);
}

but when I query for example the "phonecall" entity, I received the expected result.

Any hint?

Thanks!

  • RaviKashyap Profile Picture
    RaviKashyap 55,406 on at
    RE: Retrieving RegardingObjectId and RegardingObjectTypeCode from ActivityPointer

    Glad it worked.

    Please mark the suggestion as helpful to close the thread.

  • Zakkk Profile Picture
    Zakkk 10 on at
    RE: Retrieving RegardingObjectId and RegardingObjectTypeCode from ActivityPointer

    Hi Ravi,

    got it now. I had some activities which are not linked by regardingobjectid and that was the reason why I do not receive the attribute.

    Adding a filter to retrieve only activities with regardingobjectid not null does the trick.

                   string fetchXml =

                   @"<fetch>

                      <entity name='activitypointer'>

                          <attribute name='activitytypecode'/>

                          <attribute name='regardingobjectid'/>

                          <filter>

                              <condition attribute='regardingobjectid' operator='not-null' />

                          </filter>

                      </entity>

                   </fetch>";

                   FetchExpression fetch = new FetchExpression(fetchXml);javascript:void(0);

                   EntityCollection activities = service.RetrieveMultiple(fetch);

    Thanks for you support.

    Zakkk

  • Zakkk Profile Picture
    Zakkk 10 on at
    RE: Retrieving RegardingObjectId and RegardingObjectTypeCode from ActivityPointer

    Hi Ravi,

    thank you for you response.

    I've tried it with your FetchXml, but i was still not able to retrieve the expected column.

    Here is the code snippet:

                   string fetchXml =

                   @"<fetch>

                      <entity name='activitypointer'>

                          <attribute name='activitytypecode'/>

                          <attribute name='regardingobjectid'/>

                          <link-entity name='email' alias='e' to='activityid' from='activityid' link-type='outer'>

                              <attribute name='regardingobjectid'/>

                          </link-entity>

                          <link-entity name='phonecall' alias='p' to='activityid' from='activityid' link-type='outer'>

                              <attribute name='regardingobjectid'/>

                          </link-entity>

                      </entity>

                   </fetch>";

                   FetchExpression fetch = new FetchExpression(fetchXml);

                   EntityCollection activities = service.RetrieveMultiple(fetch);

    I received only 2 attributes. activityid and activitytypecode. But still no regardingobjectid.

    Any idea?

    Thanks

    Zakkk

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,406 on at
    RE: Retrieving RegardingObjectId and RegardingObjectTypeCode from ActivityPointer

    Hi Zakkk,

    It looks like you can't retrieve regarding from the activity pointer even though it is mentioned as the attribute in the entity metadata.

    You can try the fetch as given below (This is the sample, you need to build with all the activities)

    <fetch>

       <entity name="activitypointer" >

           <attribute name="activitytypecode" />

           <link-entity name="email" alias="e" to="activityid" from="activityid" link-type="outer" >

               <attribute name="regardingobjectid" />

               <attribute name="regardingobjecttypecode" />

           </link-entity>

           <link-entity name="phonecall" alias="p" to="activityid" from="activityid" link-type="outer" >

               <attribute name="regardingobjectid" />

               <attribute name="regardingobjecttypecode" />

           </link-entity>

       </entity>

    </fetch>

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,862 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans