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
William Roach-Barrette 5William Roach-Barrette 5 

After converting a Lightning component from Modal to header I cant spin off chatter messages

I am trying to create a lightning component that sits on a record and allows a user to create a note. The reason Im doing this is because my org needs to isolate a group of users by role and prevent them from seeing chatter. The idea is we use hashtage to convert chatter messages into notes (which already works.)

When an isolated user wants to post to chatter we want them to first add a note to the record. I was going to use the default “new Note” button baked into the related list but doing so invokes a menu with an auto-save option that makes using triggers a nightmare. So instead I used someone’s code (https://salesforce.stackexchange.com/questions/190502/lightning-components-how-to-invoke-new-note-panel-from-custom-components) to create a lightning component that would let my users post notes that are easier to monitor compared to the ContentDocumentLink and ContentVersions.

Here is where things get tricky. This is written as a modal component that needs to be triggered using a lightning action. The problem is lightning actions are stored on the Chatter feed lightning component, and in order to stop that we would need to disable feed tracking on the object this needs to work on (a non starter.)

So I converted the component as best as I could to use a simple row class to list the inputs and buttons. And now when I try to run my code I get the following error as the running user:

CUMULATIVE_PROFILING No profiling information for SOQL operations

Here is the Lightning component along with the controlling Apex class. 
New_Note.cmp
<aura:component controller="CreateNoteRecord" 
                implements="lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" 
                access="global" >
    <!-- Define Attribute-->
    <aura:attribute name="note" type="ContentNote" default="{'sobjectType': 'ContentNote','Title': '','Content': ''}"/>
    
    <div class="row">
        <h2 class = "header">Create New Note</h2>
        
        <b>Title:</b>
        <br/>
        <ui:inputText class="form-control" value="{!v.note.Title}"/>
        <br/>
        <b>Content:</b>
        <br/>
        <lightning:inputRichText value="{!v.note.Content}" placeholder="Type something interesting"/>
        <br/>
       
            <ui:button class="btn btn-default" press="{!c.create}">Create</ui:button>
            <ui:button class="btn btn-default" press="{!c.closeModel}">Cancel</ui:button>
      
        
        
    </div>

</aura:component>


New_NoteController.js
({
    create : function(component, event, helper) {
        //getting the candidate information
        var candidate = component.get("v.note");
        var noteContent = component.get("v.note.Content");
        //Calling the Apex Function
        var action = component.get("c.createRecord");
        //Setting the Apex Parameter
        action.setParams({
            nt : candidate,
            PrentId : component.get("v.recordId"),
            textConent : noteContent
           
            
        });
        //Setting the Callback
        action.setCallback(this,function(a){
            //get the response state
            var state = a.getState();
            //check if result is successfull
            if(state == "SUCCESS"){
                //Reset Form
                var newCandidate = {'sobjectType': 'ContentNote',
                                    'Title': '',
                                    'Content': ''
                                   };
                //resetting the Values in the form
                component.set("v.note",newCandidate);
            } else if(state == "ERROR"){
                alert('Error in calling server side action');
            }
        });
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
            "recordId": component.get("v.recordId"),
            "slideDevName": "detail"
        });
        navEvt.fire();
        $A.get('e.force:refreshView').fire();
        //adds the server-side action to the queue        
        $A.enqueueAction(action);
    },
    closeModel : function (component, event, helper) {
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
            "recordId": component.get("v.recordId"),
            "slideDevName": "detail"
        });
        navEvt.fire();
    }
})

CreateNewReord.apxc
public with sharing class CreateNoteRecord {
    @AuraEnabled
    public static void createRecord (ContentNote nt, id PrentId, String textConent){
        try{
            if(nt != null){
                insert nt;
                ContentDocument cd=[select id from ContentDocument where id=:nt.Id];
                textConent = textConent.replace('<p>', ' ');
                textConent = textConent.replace('</p>', ' ');
                textConent = textConent.replace('<br>' ,' ');
                ContentDocumentLink cdl=new ContentDocumentLink();
                System.debug('Text Preview: ' + textConent);
                cdl.ContentDocumentId=cd.id;
                cdl.LinkedEntityId=PrentId;
                cdl.ShareType='V';
                cdl.Visibility='AllUsers';
                FeedItem post = new FeedItem();
                post.ParentId = PrentId;
         		post.Body = textConent;
          		post.Title = nt.Title;
                insert cdl;
                insert post;
            }
        } catch (Exception ex){

        }
    }    
}


At this point im not sure what to do to get this working properly. Does anyone have a solution that might work for me?
Johanson MillerJohanson Miller
I was looking for the information regarding the same.