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 :
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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 81 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans