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
freynoldsfreynolds 

SOSL Find after insert

Well, I'm making a custom chatter integration (I need basically to use different chatter feeds for different parts of an account process) so I started using hashtags to contextualize each vf page.

 

My issue, (that isn't that bad) is that for me to contextualize I need to do a SOSL query to get the itemfeeds that have this particular hashtag (it changes on each page)  and after I make an insert, it takes arround a minute to about 2-3 so that the new post appears in the find sentence.

 

Anyone has any idea on how to solve this?

 

My itemfeed setter (body is set in the vf and I just  add the hashtag of any page)

    public void ShareFeedItem() {
        newFeedItem.ParentId = objectId;
        
        if(hashtag != null)
            newFeedItem.Body = hashtag + ' ' + newFeedItem.Body;
        
        newFeedItem.Type = 'TextPost'; 
        insert newFeedItem;
    }

 

one (of the serveral querys I have (I also use custom objects and opportunities to attach to the feed)

                    searchList =  [FIND :this.hashtag IN BODY FIELDS RETURNING FeedItem];
                
                    this.myFeed = [SELECT Id, ParentId, Parent.name, Type, CreatedById, CreatedBy.name, CreatedDate, IsDeleted, 
                           SystemModstamp, CommentCount, LikeCount, Title, Body, LinkUrl, RelatedRecordId, ContentData,
                           ContentFileName, ContentDescription, ContentType, ContentSize, InsertedById, LastModifiedDate,
                          (SELECT Id, FieldName, OldValue, NewValue FROM FeedTrackedChanges),
                          (SELECT Id, CreatedDate, CreatedById, CreatedBy.Name, CommentBody FROM FeedComments ORDER BY CreatedDate DESC)
                           FROM FeedItem WHERE  ParentId = :this.objectId AND id IN :searchList[0]];

 

My regards,

Francis.

bob_buzzardbob_buzzard

The indexing of records is carried out by a separate process on the platform, so there's nothing that you can do to influence this I'm afraid.  If you need to be able to retrieve the details immediately after insert, then SOQL is the way to go. 

freynoldsfreynolds

Thank you for your response! Soql only won't work because I need to filter the body field of FeedItem and sf has a limit on that.

 

My solution, is to make a list (<List<SObject>) that it adds the insertion id and after I search in the sosl add to the returning array the ids, its ugly and it might get me some duplicate feeditems but it's the only way to go if the indexing can't be controled.

 

Bye.

 

Pd: If anyone has a better idea, I'm all ears.