In this post i want mention the user. I'm using the connect apex chatter.
I'don't know how mention the user with u.id,and now i'm getting an error:
FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object
Please can you take a look to my code?
Thank you in advance.
Global class RandomPilot implements Schedulable{
//FOR TEST METHOD
public static String CRON_EXP = '0 0 0 3 9 ? 2022';
Global void execute(SchedulableContext sc)
{
// SEARCH BY STATIC RESOURCE NAME
// Post a feed item that has an @-mention.
String communityId = null;
for(User u:lstu)
{
// CREATE A FEED_ITEM_TEXT
String feedItemText= 'Happy Birthday!';
ConnectApi.FeedItemInput feedItemInput = FeedBodyParser.convertToFeedItemInput(feedItemText);
// POST FILE_FEED_ITEM
ConnectApi.NewFileAttachmentInput fileIn = new
ConnectApi.ChatterFeeds.postFeedItem(communityId,ConnectApi.FeedType.Record,fgroup.id, feedItemInput, feedBinary);
}
}
}