• Johanson Miller
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

How can i change the Prefix of all the customfields for the complete project.

Example: I want to change the current custom fields across the project with a prefix as : XYZ_ (example: i have custom field as PhoneNumber__c and i want to change as XYZ_PhoneNumber__c) do we have any option through any third party tool or app exchange app or jsut do it manually. Your Help would be reallu appreciated.

Regards
Ravi 

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?