2

I'm attempting to tag a users in a custom lwc component. THis is my current code.

@AuraEnabled
public static void postFeedItem(String msgTxt, String recordId){        
    ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), recordId, ConnectApi.FeedElementType.FeedItem, msgTxt);
}

This lets me comment but @mention functionality with chatter notification isn't present.

I tried using ConnectApi.MentionSegmentInput and then inserting this in MessageInput, but didn't get any mention suggestions or proposals like the standard chatter functionality. Kindly point me to the right direction.

EDIT: My attempt so far:

  1. On the lightning-input as text I triggered the apex db call as soon its "@" and >3 chars.

  2. I am able to select that user Id.

  3. Next move is to post the feed using the chattermention method in connect Api.

        <lightning-input    "
      data-id="search-input"
        value={searchValue}
        placeholder="Search by user first name or last name"
        onchange={searchKeyword}
        label="Tag User"
        required
    ></lightning-input>
    
    
    <template if:true={showRecordList}>
        <ul data-id="waiver-list" class="slds-has-dividers_bottom-space container-border" if:true={userRecord}>
            <template for:each={userRecord} for:item="userList">
                <li key={userList.Id} 
                class="slds-item"
                data-id={userList.Id}
                data-name={userList.Name}
                onclick={selectedId}>{userList.Name}</li>
            </template>
        </ul>
    </template>
    
3
  • 1
    Check this one: salesforce.stackexchange.com/questions/339605/…
    – Pavan tej
    Dec 29, 2021 at 12:15
  • Thanks @Pavantej I did go through that article already, it uses js lib, I was hoping for a std implementation to leverage.
    – MnZ
    Dec 29, 2021 at 13:35
  • @Mnz, did you manage to get this done?
    – glls
    Jan 10, 2022 at 2:51

1 Answer 1

2

You need to use postFeedItemWithMentions instead of postFeedElement. There are numerous examples online on how to achieve this:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .