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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Create activity post by plugin

(0) ShareShare
ReportReport
Posted on by 115

How to create a post entity and link it to the timline of an opportunity?

When i try the following i get an error "The given key was not present in the dictionary". Am i setting the OptionSetValue wrong or something else?


pastedimage1625845365867v1.png

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    The error provided is usually the marker that one of the fields that were expected was not passed at all.

    Try to add the "text" field as well.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    I think there is no field called "Type" in Post entity , so change it to "text" which is text field

    because the error "The given key was not present in the dictionary" means that you use some attribute (Logical Name) which is not present in your entity

  • Verified answer
    AndreasB83 Profile Picture
    115 on at

    There is a parameter type (e.g. "idea", "news" and so on) and a parameter source (values like "manual" or "automatic").

    I forgot to set a text but there seems to be an default emtpy string for that. Turns out a few rows above i had something like

    OP["fc_aiprog" = Convert.ToDouble(OP["fc_aiprog");

    to recieve the old value of an field which will be updated. But in this case that specific opportunity did not have any value till now.

    That caused the "The given key was not present in the dictionary".

    The post ist created fine now like this:

    Entity timelinePost = new Entity("post");
    
    timelinePost["regardingobjectid"] = new EntityReference("opportunity",OP.Id);
    
    timelinePost["text"] = "Neuer AI-Prog: "   prognosisdata.fc_aiprog   "% (Plugin)";
    
    OptionSetValue sourceVal = new OptionSetValue(1);
    
    timelinePost["source"] = sourceVal; // Manual or Automatic
    
    OptionSetValue postType = new OptionSetValue(7);
    
    timelinePost["type"] = postType; // type of post i.e idea or news etc
    
    client.Create(timelinePost);

    Thanks to everybody for your support!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 119

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans