Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Unable to get account id from the task created in it

(0) ShareShare
ReportReport
Posted on by

I created a plugin and a post image on creation of a task. I am unable to get the account id for which the task is created 

I'm using the following command 

((Entity)context.PostEntityImages["taskCreate"]).Attributes["regardingobjectid"].ToString();

where taskCreate is the image that I have created with PRT

*This post is locked for comments

  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    2,545 on at
    RE: Unable to get account id from the task created in it
    Hi,
    Please find the code:
     
    //C# code plugin code
    Entity postImage = context.PostEntityImages["taskCreate"];
                    string accountId = string.Empty;
                    if (postImage!=null && postImage.GetAttributeValue<EntityReference>("regardingobjectid") != null)
                    {
                        EntityReference regardingEntityReference = postImage.GetAttributeValue<EntityReference>("regardingobjectid");
                        accountId = regardingEntityReference.Id.ToString();
                    }
       
  • Community Member Profile Picture
    on at
    RE: Unable to get account id from the task created in it

    the output I get for the above thing is  Microsoft.Xrm.Sdk.EntityReference

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans