web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Retrieving RegardingObjectId and RegardingObjectTypeCode from ActivityPointer

(0) ShareShare
ReportReport
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!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator 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>

  • Zakkk Profile Picture
    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

  • Zakkk Profile Picture
    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

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

    Glad it worked.

    Please mark the suggestion as helpful to close the thread.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans