function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JohnDTheMavenJohnDTheMaven 

Bug with ConnectApi.​FeedSortOrder - Invalid Type

Based on the documentation seen here (http://www.salesforce.com/us/developer/docs/apexcode/Content/connectAPI_enums.htm#FeedSortOrder_enum), ConnectApi.FeedSortOrder is a valid Apex Enum.  However when I try to save this simple class with v28.0 through v31.0, I get the followin error "Compilation error: Invalid type: ConnectApi.​FeedSortOrder".  Here is the Apex class to reproduce the error

public with sharing class scratch
{
    private ConnectApi.​FeedSortOrder fso = ConnectApi.​FeedSortOrder.LastModifiedDateDesc;
}

Chatter is enabled in this org and other ConnectApi.ChatterFeeds related classes are working.

It would appear that the Apex compiler doesn't recognize ConnectApi.​FeedSortOrder enum as a valid Apex object.
Best Answer chosen by JohnDTheMaven
Jim JamJim Jam
i don't think enums are treated as valid object types in Apex. They are used as parameters in method calls. Refer to the ChatterFeeds class for further info.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ConnectAPI_ChatterFeeds_static_methods.htm#apex_ConnectAPI_ChatterFeeds_getFeedElementsFromFeed_6

so, you could do the following for example .. ConnectApi.FeedItemPage feedItemPage = ConnectApi.ChatterFeeds.getFeedItemsFromFeed(null, ConnectApi.FeedType.Bookmarks, 'me', null, null, ConnectApi.FeedSortOrder.CreatedDateDesc);

All Answers

Jim JamJim Jam
i don't think enums are treated as valid object types in Apex. They are used as parameters in method calls. Refer to the ChatterFeeds class for further info.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_ConnectAPI_ChatterFeeds_static_methods.htm#apex_ConnectAPI_ChatterFeeds_getFeedElementsFromFeed_6

so, you could do the following for example .. ConnectApi.FeedItemPage feedItemPage = ConnectApi.ChatterFeeds.getFeedItemsFromFeed(null, ConnectApi.FeedType.Bookmarks, 'me', null, null, ConnectApi.FeedSortOrder.CreatedDateDesc);
This was selected as the best answer
JohnDTheMavenJohnDTheMaven
Ok.  I see what you are talking about.  That does work now.  Thanks!