Try our conversational search powered by Generative AI!

Adding new rooms/topics and immediately getting ID back


See code below:

Topic relateTopic = new Topic(currentPage.GetForumRoom(), topic.Title, topic.Body, new UserAuthor(CurrentCommunityUser));

return RedirectToAction("ViewTopic", new { id = relateTopic.ID });


In the above, the relateTopic.ID is always -1.  How do I immediately get the newly created topic ID back so I can take some further action with it? 

Aug 11, 2014 20:11

Hi Shawn,

According to the SDK this is how it is suppose to be done, the AddTopic method takes a topic and persists it in the database. However I see that you do not use the return value from AddTopic and assign it to your created topic:

relateTopic = ForumHandler.Instance.AddTopic(relateTopic);


Aug 12, 2014 1:20
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.