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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Programmatically set user to follow a record (postfollow entity)

(0) ShareShare
ReportReport
Posted on by

Hi,

In my plugin I want to create  a record of postfollow entity. I want to be able to set a user to follow a record, for example User A to follow Opportunity B.

Problem is that if we specify "owninguser" attribute in the postfollow object, no create is being made (but no exception is thrown). If I just specify "regardingobjectid" attribute it works, but then it will be my user (running user) that will be the owner of the postfollow record ; i.e. it will be me who is following the Opportunity..

AssignRequest does not allow postfollow entity to be specified either, so we can't create it for running user and assign it to a new owner..

All information I've found online just state that you can set owner and regarding record to create the follow-relationship between the two. 

Please help

*This post is locked for comments

I have the same question (0)
  • Deepesh161 Profile Picture
    6,317 on at

    Can you put your code here?

  • Community Member Profile Picture
    on at

    Hi, sure.

    Guid userid = new Guid("188A3D7C-3064-E411-943C-00155D029D1F");

    Guid pitch = new Guid("D9728515-CC7E-E411-943F-00155D029D1F");

    Entity postfollow = new Entity("postfollow");

    postfollow.Attributes["regardingobjectid"] = new EntityReference("opportunity", pitch);

    postfollow.Attributes["owninguser"] = new EntityReference("systemuser", userid);

    Guid postfollowId = service.Create(postfollow);

    And this is what I tried to see if we could assign the postfollow to the correct user after creating it (which does not work, because the entity cannot be assigned).

    //AssignRequest assign = new AssignRequest

    //{

    //    Assignee = new EntityReference("systemuser",

    //        userid),

    //    Target = new EntityReference("postfollow",

    //        postfollowId)

    //};

    I also tried with "createdonbehalfby" instead of owninguser, but with no success.

  • Verified answer
    Deepesh161 Profile Picture
    6,317 on at

    Please correct this line and it will work fine:

    Use  postfollow.Attributes["ownerid"] = new EntityReference("systemuser", userid);

    instead of postfollow.Attributes["owninguser"] = new EntityReference("systemuser", userid);

    I checked and it works fine.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans