You need to sign in to do that
Don't have an account?
Hermann Oure 6
Creation @mention custom feed quick action
Hi,
I would like to be able to mention users with @mention in my custom feed quick action
I have created a lightning quick action called "Coworking Comm" on case feed so Company users can communicate internally on cases of certain type that we call "coworking cases".
And I would like for any user to tag or mention another user. Similar to the post feed as shown below:
Thank you
I would like to replicate the same thing with @mention in "coworking comm" quick action.
here is are my codes:
<--- .cmp: --->
<aura:component controller="CoworkingComm" implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="textPost" type="String" />
<aura:attribute name="thisCase" type="Case" default="{ 'sobjectType': 'Case' }"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<div class="coworking_comm">
<lightning:inputRichText variant="bottom-toolbar" value="{!v.textPost}" formats="['bold','italic','underline','strike','list','clean']" shareWithEntityId="{!v.recordId}">
<lightning:insertImageButton />
</lightning:inputRichText>
</div>
<div class="coworking_comm"><lightning:button label="Share" onclick="{!c.shareComm }"/></div>
</aura:component>
<--- controller.js: --->
({
doInit: function(cmp) {
cmp.set('v.textPost', '<p><script>alert(this)</script></p><p>hi!</p>');
},
shareComm : function (component, event, helper) {
var action = component.get("c.ctrlShareComm");
action.setParams({
caseid: component.get("v.recordId"),
textPost: component.get("v.textPost")
});
//force refresh of the page
action.setCallback(this, function(data) {
var result = data.getReturnValue();
$A.get('e.force:refreshView').fire();
});
//Queue the action
$A.enqueueAction(action);
},
});
<--- controller.apxc: --->
public with sharing class CoworkingComm {
@AuraEnabled
public static Case getCase(string caseid){
Case c = [SELECT Id,Status,Owner.Type,First_Reply_Date__c FROM Case WHERE Id=:caseid LIMIT 1];
return c;
}
@AuraEnabled
public static string ctrlShareComm (String caseid, String textPost)
{
string result = 'success';
// REMOVE BR FROM TEXTPOST
textPost = textPost.replaceAll('<br>','<p> </p>');
textPost = textPost.replaceAll('strike>','s>');
// CREATE FEED ITEM AND POST IT
FeedItem post = new FeedItem();
post.ParentId = caseid;
post.IsRichText = true;
post.type = 'LinkPost';
post.Body = textPost;
post.Visibility = 'InternalUsers';
try{
insert post;
//ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement('InternalUsers',caseid,ConnectApi.FeedElementType.FeedItem,textPost);
}
catch(Exception e)
{
System.debug('CoworkingCommunicationController - Error inserting post');
return 'post_error';
}
return 'case_error';
}
}
I would like to be able to mention users with @mention in my custom feed quick action
I have created a lightning quick action called "Coworking Comm" on case feed so Company users can communicate internally on cases of certain type that we call "coworking cases".
And I would like for any user to tag or mention another user. Similar to the post feed as shown below:
Thank you
I would like to replicate the same thing with @mention in "coworking comm" quick action.
here is are my codes:
<--- .cmp: --->
<aura:component controller="CoworkingComm" implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="textPost" type="String" />
<aura:attribute name="thisCase" type="Case" default="{ 'sobjectType': 'Case' }"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<div class="coworking_comm">
<lightning:inputRichText variant="bottom-toolbar" value="{!v.textPost}" formats="['bold','italic','underline','strike','list','clean']" shareWithEntityId="{!v.recordId}">
<lightning:insertImageButton />
</lightning:inputRichText>
</div>
<div class="coworking_comm"><lightning:button label="Share" onclick="{!c.shareComm }"/></div>
</aura:component>
<--- controller.js: --->
({
doInit: function(cmp) {
cmp.set('v.textPost', '<p><script>alert(this)</script></p><p>hi!</p>');
},
shareComm : function (component, event, helper) {
var action = component.get("c.ctrlShareComm");
action.setParams({
caseid: component.get("v.recordId"),
textPost: component.get("v.textPost")
});
//force refresh of the page
action.setCallback(this, function(data) {
var result = data.getReturnValue();
$A.get('e.force:refreshView').fire();
});
//Queue the action
$A.enqueueAction(action);
},
});
<--- controller.apxc: --->
public with sharing class CoworkingComm {
@AuraEnabled
public static Case getCase(string caseid){
Case c = [SELECT Id,Status,Owner.Type,First_Reply_Date__c FROM Case WHERE Id=:caseid LIMIT 1];
return c;
}
@AuraEnabled
public static string ctrlShareComm (String caseid, String textPost)
{
string result = 'success';
// REMOVE BR FROM TEXTPOST
textPost = textPost.replaceAll('<br>','<p> </p>');
textPost = textPost.replaceAll('strike>','s>');
// CREATE FEED ITEM AND POST IT
FeedItem post = new FeedItem();
post.ParentId = caseid;
post.IsRichText = true;
post.type = 'LinkPost';
post.Body = textPost;
post.Visibility = 'InternalUsers';
try{
insert post;
//ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement('InternalUsers',caseid,ConnectApi.FeedElementType.FeedItem,textPost);
}
catch(Exception e)
{
System.debug('CoworkingCommunicationController - Error inserting post');
return 'post_error';
}
return 'case_error';
}
}
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_feed_element_mention.htm
Using apex it is possible. There is no standard tag to tag users.
--
Magulan Duraipandian
www.infallibletechie.com