+ Start a Discussion
Brett Roberts 15Brett Roberts 15 
I need to create a custom formula field on the account that evaluates the owner ID of an account and then fills a field out with a text value (a name).

Here is the breakdown I need.

Owner ID 1 = Name 1
Owner ID 2 & 3 = Name 2
Owner ID 3 & 4 = Name 3

Any ideas?
Best Answer chosen by Brett Roberts 15
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Brett,

Thanks for confirming. Can you try thr below formula. Replace the ownerids as per your requirement.
 
if( OwnerId ='0055j000000XLmV', 'sample1' , if( OR(OwnerId ='0055j000000XERR',OwnerId ='0055j000000XERT'),'SAMPLE2', IF(OwnerId='0055j000000Xfs4', 'SAMPLE3','')

)

)

If this solution helps, Please mark it as best answer.

Thanks,
 
jdeveloperjdeveloper 

hi, im new to salesforce and i was wondering what was the difference between __c and __r when refering to a custom object. Also can u give me examples. thanks

Best Answer chosen by Admin (Salesforce Developers) 
nylonnylon

Hi,

 

"__r" is used for retrieving field values from the object's related another object when those objects have relationship via Lookup field.

See links below for detail and samples.

 

In Formula:

http://developer.force.com/cookbook/recipe/displaying-fields-from-a-related-record-on-a-detail-page

In SOQL:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm

David NikoliDavid Nikoli 
I am running a e com store and just created the website. Now my business is growing and i want to make mobile app of best japanese vegetable knives (https://toolsofchef.com/best-japanese-vegetable-knives/) my store. Is there a developer here who can tell me how much it would cost to build a mobile app?
Best Answer chosen by David Nikoli
ANUTEJANUTEJ (Salesforce Developers) 
Hi David,

Please be advised that this community is focused on Salesforce technical discussions where the forums and participants are geared toward programming troubleshooting and support. 
I would request you to not post such posts on this forum going forward.

You might want to consider posting this information on job portals for the right visibility.

Please close the thread by selected as Best Answer so that we can keep our community clean.

Regards,
Salesforce Support
Ben SimonsBen Simons 
I'm having an issue getting this error: 

Challenge Not yet complete... here's what's wrong: 
The license and profile are set incorrectly for Ada Balewa.

Now, I have tried EVERY user profile/license combination available, and none seem to work for Ada Balewa... I also have issues with having the second User active (I can only seem to have myself and one other user active which is currently Shinje as per the instructions), I've also tried creating a custom profile with "Moderate Chatter" selected, but the error still remains the same, and I've hit a hurdle...
Best Answer chosen by Ben Simons
Dave ParadiseDave Paradise
Hi Ben,

I finished this challenge this morning and did run into a couple of snags with some user settings.

For Ada Balewa, she will not have a role but will have the Chatter Free User Licence and Chatter Moderator User Profile. Since she is not a Salesforce User, she will be allowed to be Active along with Shinje.

Good luck!
inbox outbox 7inbox outbox 7 
I am looking for a scenario as to, when we use apex sharing over declarative ways. 
 
Thank you!
Best Answer chosen by inbox outbox 7
Tushar KhorateTushar Khorate
Apex managed sharing must use an Apex sharing reason . Apex sharing reasons are a way for developers to track why they shared a record with a user or group of users. Using multiple Apex sharing reasons simplifies the coding required to make updates and deletions of sharing records.
Manual Sharing
Manual Sharing is used to share the record Manually. For Example, you are working on an Opportunity record and You need help from your colleague. In this case, you can share the record with him/her and take the help.
Manual Sharing is not available for Lightning Experience
Click here for Manual Sharing for Salesforce Lightning.
Apex Managed Sharing
Apex Managed Sharing only works when the OWD is either private or Public Read Only.
Apex Managed Sharing is used to share the records when you can not use Sharing rules.
We do insert the Share Record using Apex trigger/class.
Maintained across ownership changes
Requires “Modify All” permission

For more detail information see this: https://www.youtube.com/watch?v=9ZnMNPBJ5D0&ab_channel=SFDCPanther%2B (https://www.youtube.com/watch?v=9ZnMNPBJ5D0&ab_channel=SFDCPanther%2B)
If you found this helpful then mark it as best answer so other can also see this if they want help.

Thank you
Nishant SharmaNishant Sharma 
Not sure, what is wrong with following code. While validating, it give me following error:
The campingList component isn't handing the added item correctly.

Here is the code:
1. camping.cmp
<aura:component >
    <c:campingHeader />
    <c:campingList />
</aura:component>
2. CampingList.cmp
<aura:component controller="CampingListController">
    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:handler name="addItem" action="{!c.handleAddItem}" event="c:addItemEvent"/>
    
    <c:campingListForm />
    
    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Expenses</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                    <br/>
                </aura:iteration>
            </div>
        </section>
    </div>
    
</aura:component>

3. campingListController.js
({
    // Load expenses from Salesforce
    doInit: function(component, event, helper) {
        
        // Create the action
        var action = component.get("c.getItems");
        
        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        
        // Send action off to be executed
        $A.enqueueAction(action);
    },
    
    handleAddItem : function(component, event, helper) {
        
        var action = component.get("c.saveItem");
        action.setParams({
            "item": JSON.parse(JSON.stringify(event.getParam("item")))
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var items = component.get("v.items");
                items.push(response.getReturnValue());
                component.set("v.items", items);
            }
        });
        $A.enqueueAction(action);
    }
})

4. componentListHelper.js
({
    createCamping: function(component,item) {
        
        var action = component.get("c.saveItem");
        action.setParams({
            "item": JSON.parse(JSON.stringify(item))
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var items = component.get("v.items");
                items.push(response.getReturnValue());
                component.set("v.items", items);
            }
        });
        $A.enqueueAction(action);
    }
})
5. campingListForm.cmp
<aura:component >
    
    <aura:attribute name="newItem" type="Camping_Item__c"
                    default="{ 'sobjectType': 'Camping_Item__c',
                             'Name': '',
                             'Packed__c': false,
                             'Price__c': '0',
                             'Quantity__c': '0' }"/>
    
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
    
    <div aria-labelledby="newitemform">
        <fieldset class="slds-box slds-theme--default slds-container--small">
            
            <legend id="newitemform" class="slds-text-heading--small 
                                            slds-p-vertical--medium">
                Add Camping Item
            </legend>
            
            <form class="slds-form--stacked">
                
                <div class="slds-form-element slds-is-required">
                    <div class="slds-form-element__control">
                        <ui:inputText aura:id="name" label="Camping Item Name"
                                      class="slds-input"
                                      labelClass="slds-form-element__label"
                                      value="{!v.newItem.Name}"
                                      required="true"/>
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <ui:inputCheckbox aura:id="packed" label="Packed?"
                                      class="slds-checkbox"
                                      labelClass="slds-form-element__label"
                                      value="{!v.newItem.Packed__c}"/>
                </div>
                
                <div class="slds-form-element">
                    <div class="slds-form-element__control">
                        <ui:inputCurrency aura:id="price" label="Price"
                                          class="slds-input"
                                          labelClass="slds-form-element__label"
                                          value="{!v.newItem.Price__c}" />
                        
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <div class="slds-form-element__control">
                        <ui:inputNumber aura:id="quantity" label="Quantity"
                                        class="slds-input"
                                        labelClass="slds-form-element__label"
                                        value="{!v.newItem.Quantity__c}"/>
                        
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <ui:button label="Create Camping Item"
                               class="slds-button slds-button--brand"
                               press="{!c.submitForm}"/>
                </div>
                
            </form>
            
        </fieldset>
    </div>
    
</aura:component>
6. campingListFormController
({    
    
    submitForm : function(component, event, helper) {
        
        var validCamping = true;

        // Name must not be blank
        var nameField = component.find("name");
        var expname = nameField.get("v.value");
        if ($A.util.isEmpty(expname)){
            validCamping = false;
            nameField.set("v.errors", [{message:"Camping Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }

        
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price) || isNaN(price) || (price <= 0.0)){
            validCamping = false;
            priceField.set("v.errors", [{message:"Camping Item price can't be blank."}]);
        }
        else {
            priceField.set("v.errors", null);
        }
        
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        if ($A.util.isEmpty(quantity) || isNaN(quantity) || (quantity <= 0)){
            validCamping = false;
            quantityField.set("v.errors", [{message:"Camping Item quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }

        if(validCamping){
            
            helper.createItem(component);
        }
    },
})

7. campingListFormHelper.js
({
    
     createItem : function(component) {
        var newItem = component.get("v.newItem");
        var addEvent = component.getEvent("addItem");
        addEvent.setParams({"item" : newItem});
        addEvent.fire();
        component.set("v.newItem",
                     { 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Packed__c': false,
                    'Price__c': 0,
                    'Quantity__c': 0});
    }
})

8. addItemEvent.evt
<aura:event type="COMPONENT" description="Event template">
    <aura:attribute name="item" type="Camping_Item__c"/>
</aura:event>

It works well, when I test this app. any thought? Can anyone share the working code for this module?


 
Best Answer chosen by Nishant Sharma
Nayana KNayana K
Seems handleAddItem method body of campingListController.js should be :
 
handleAddItem: function(component, event, helper) {
        var item = event.getParam("item");
                
        var action = component.get("c.saveItem");
//json stringify is not needed I think.       
action.setParams({
            "item": item
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {        
                var items = component.get("v.items");
                items.push(item);
                component.set("v.items",items);
            }
        });
        $A.enqueueAction(action);
    }

Just for reference I will post whole code :

campingList.cmp
<aura:component controller="CampingListController">
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}"/>
    
    <div class="slds-page-header" role="banner">

      <div class="slds-grid">

        <div class="slds-col">

          <p class="slds-text-heading--label">Camping Items</p>

          <h1 class="slds-text-heading--medium">My Camping Items</h1>

        </div>

      </div>

    </div>

      
  <div aria-labelledby="newitemform">

      <fieldset class="slds-box slds-theme--default slds-container--small">
    
        <c:campingListForm />
    
      </fieldset>

	</div>
    
    
     <aura:attribute name="items" type="Camping_Item__c[]"/>

    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Camping List Items</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>

</aura:component>

campingListController.js
({
    
    doInit: function(component, event, helper) {
    
        var action = component.get("c.getItems");
    
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
    
        $A.enqueueAction(action);
    },    
    
    handleAddItem: function(component, event, helper) {
        var item = event.getParam("item");
                
        var action = component.get("c.saveItem");
        action.setParams({
            "item": item
        });
        
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {        
                var items = component.get("v.items");
                items.push(item);
                component.set("v.items",items);
            }
        });
        $A.enqueueAction(action);
    }
    
})

campingListHelper.js
({
	createItem : function(component, item) {
        var action = component.get("c.saveItem");
    action.setParams({
        "item": item
    });
    action.setCallback(this, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            var items = component.get("v.items");
            items.push(response.getReturnValue());
            component.set("v.items", items);
            component.set("v.newItem",{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Quantity__c': 0,
                    'Price__c': 0,
                    'Packed__c': false });
        }
    });
    $A.enqueueAction(action);
		/*var theItems = component.get("v.items");
 
        // Copy the expense to a new object
        // THIS IS A DISGUSTING, TEMPORARY HACK
        var newItem = JSON.parse(JSON.stringify(item));
 
        theItems.push(newItem); 
        component.set("v.items", theItems);
       console.log('theItems helper==',theItems);*/
    
	},
    
    validateItemForm: function(component) {

    // Simplistic error checking
    var validExpense = true;

    // Name must not be blank
    var fld = component.find("ciName");
    var fldVal = fld.get("v.value");
    if ($A.util.isEmpty(fldVal)){
        validExpense = false;
        fld.set("v.errors", [{message:"Name can't be blank."}]);
    }
    else {
        fld.set("v.errors", null);
    }

    // Amount must be set, must be a positive number
    var quantFld = component.find("ciQuantity");
    var quantFldVal = quantFld.get("v.value");
    if ($A.util.isEmpty(quantFldVal) || isNaN(quantFldVal) || (quantFldVal <= 0.0)){
        validExpense = false;
        quantFld.set("v.errors", [{message:"Enter qunatity."}]);
    }
    else {
        // If the amount looks good, unset any errors...
        quantFld.set("v.errors", null);
    }
        
        // Amount must be set, must be a positive number
    var priceFld = component.find("ciPrice");
    var priceFldVal = priceFld.get("v.value");
    if ($A.util.isEmpty(priceFldVal) || isNaN(priceFldVal) || (priceFldVal <= 0.0)){
        validExpense = false;
        priceFld.set("v.errors", [{message:"Enter price."}]);
    }
    else {
        // If the amount looks good, unset any errors...
        priceFld.set("v.errors", null);
    }
    
    return(validExpense);
}
})
campingListForm.cmp
<aura:component >
    
     <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Packed__c': false,
                    'Price__c': '0',
                    'Quantity__c': '0' }"/>
	<aura:registerEvent name="addItem" type="c:addItemEvent"/>
    
  <div aria-labelledby="newitemform">
      <fieldset class="slds-box slds-theme--default slds-container--small">
    
        <legend id="newitemform" class="slds-text-heading--small 
          slds-p-vertical--medium">
          Add Camping Item
        </legend>
    
        <form class="slds-form--stacked">
    
          <div class="slds-form-element slds-is-required">
              <div class="slds-form-element__control">
                  <ui:inputText aura:id="name" label="Camping Item Name"
                      class="slds-input"
                      labelClass="slds-form-element__label"
                      value="{!v.newItem.Name}"
                      required="true"/>
              </div>
         </div>
            
          <div class="slds-form-element">
              <ui:inputCheckbox aura:id="packed" label="Packed?"
                  class="slds-checkbox"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Packed__c}"/>
          </div>
            
        <div class="slds-form-element">
              <div class="slds-form-element__control">
                  <ui:inputCurrency aura:id="price" label="Price"
                      class="slds-input"
                      labelClass="slds-form-element__label"
                      value="{!v.newItem.Price__c}" />
    
              </div>
          </div>
    
         <div class="slds-form-element">
              <div class="slds-form-element__control">
                  <ui:inputNumber aura:id="quantity" label="Quantity"
                      class="slds-input"
                      labelClass="slds-form-element__label"
                      value="{!v.newItem.Quantity__c}"/>
    
              </div>
          </div>
    
          <div class="slds-form-element">
              <ui:button label="Create Camping Item"
                  class="slds-button slds-button--brand"
                  press="{!c.submitForm}"/>
          </div>
    
        </form>
    
      </fieldset>
</div>

</aura:component>

campingListFormController.js
({    
    
    submitForm : function(component, event, helper) {
        
        var validCamping = true;

        // Name must not be blank
        var nameField = component.find("name");
        var expname = nameField.get("v.value");
        if ($A.util.isEmpty(expname)){
            validCamping = false;
            nameField.set("v.errors", [{message:"Camping Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }

        
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price) || isNaN(price) || (price <= 0.0)){
            validCamping = false;
            priceField.set("v.errors", [{message:"Camping Item price can't be blank."}]);
        }
        else {
            priceField.set("v.errors", null);
        }
        
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        if ($A.util.isEmpty(quantity) || isNaN(quantity) || (quantity <= 0)){
            validCamping = false;
            quantityField.set("v.errors", [{message:"Camping Item quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }

        if(validCamping){
            
            helper.createItem(component);
            
        }
        
    },
})

campingListFormHelper.js
({

     createItem : function(component) {
        var newItem = component.get("v.newItem");
        var addEvent = component.getEvent("addItem");
        addEvent.setParams({"item" : newItem});
        addEvent.fire();
        component.set("v.newItem",
                     { 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Packed__c': false,
                    'Price__c': 0,
                    'Quantity__c': 0});
    }

})


 
Liam JeongLiam Jeong 
Hey folks,

I would like to create a custom report type for Approval History(ProcessInstanceStep).

My first approach was creating a trigger or record-triggered flow on the ProcessInstanceStep object.
But for some reason, Salesforce doesn't allow me to create a trigger on the object.

Background information,
There are more than 2,000 submitted approvals daily based.
The client wants to maximize declarative tools' usability.(Not Programatical solution)

How should I resolve this issue?

Much obliged, in advance.
Liam
Best Answer chosen by Liam Jeong
Naveen KNNaveen KN
Thanks for the details, Liam.

I was in the assumption that it is for a single object. Then, it will be difficult to handle all the approval processes(multiple objects) from a single place.

I think we have to Go with Batch apex now!

--
Naveen 
 
jonathanrico.jonathanrico. 

Hello Everyone,

 

Does anyone know if its possible to bring the translated value of a Picklist field in a Text Formula Field.

 

I currently have a status picklist field in Object A. Object B is a detail of Object A and I need to display the value of the status field in Object B.

 

I need to support multiple languages, however, when using translations the picklist label translates perfectly at the Object A level but the child records of Object B display the original value.

 

I guess formula fields always retrieve the master labels, is there anyway to get around this in order to get the translated value?

 

Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
Ispita_NavatarIspita_Navatar

I think this is an idea for this type of problem faced by another person. You can go and promote the idea and may be in the subsequent releases this may be released as a feature.

 

The following was the response to such a post:-

 

I have investigated this request 
and have found that there is no practical
way of returning the translated value in the
formula field using the standard
functionality of Salesforce.


Something you could look into
would be to use a trigger to return
the translated value by incorporating
the function mentioned on this page:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_a

 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

Durgesh VyasDurgesh Vyas 
I want to disable personalize nav bar options for users.
Best Answer chosen by Durgesh Vyas
Dinesh GopalakrishnanDinesh Gopalakrishnan
Hi Durgesh,

Please check the Below Options or check the Doc from the Below Link
  • If you don’t want your users to personalize the navigation bar for a specific app, disable personalization. From Setup in Lightning Experience, go to the App Manager. For the desired app, select App Options. Select Disable end user personalization of nav items in this app.
  • If you don’t want your users to personalize the navigation bar for any app, disable personalization. From Setup, enter User Interface in the Quick Find box, then select User Interface. Select Disable Navigation Bar Personalization in Lightning Experience. Salesforce recommends disabling navigation personalization by app instead of for the entire org.
https://help.salesforce.com/articleView?id=user_userdisplay_tabs_lex_considerations.htm&type=5

Kindly Mark this as a Best Answer if you Find this Useful!

Thanks
DineshKumar Gopalakrishnan
Oscar Fernando De la CruzOscar Fernando De la Cruz 
Hi everyone, I'm  new on LWC . and  I'm doing  this example to generate a PDF https://santanuboral.blogspot.com/2020/10/lwc-generate-pdf.html
everything works fine  but now Im trying to save the PDF to  the  correspondet contact depending on the ID,  any idea of how I can do that?   this is my code as we can see Im hard coding the id 

 
public with sharing class DisplayRichTextHelper {
    @AuraEnabled
public static Attachment generatePDF(String txtValue){

        Pagereference pg = Page.renderAsPDF;
        pg.getParameters().put('displayText', txtValue);

        Contact con = new Contact(Id='0035f000008RNWCAA4');

        Attachment objAttachment = new Attachment();
        objAttachment.Name = 'J2S.pdf';
        objAttachment.ParentId = con.Id;
        objAttachment.Body = pg.getContentaspdf();
        objAttachment.IsPrivate = false;
        insert objAttachment;
        return objAttachment;
    }
}
 

And i want to change for some like this:
 ApexPages.currentPage().getParameters().get('id');
Best Answer chosen by Oscar Fernando De la Cruz
Maharajan CMaharajan C
Hi Oscar,

I hope you are using this LWC Component in Contact Record Page.

Please add the below changes in your code.

Apex Class:
 
public with sharing class DisplayRichTextHelper {
    
    @AuraEnabled
    public static Attachment generatePDF(String txtValue, String contactId){
        Pagereference pg = Page.renderAsPDF;
        pg.getParameters().put('displayText', txtValue);
        Attachment objAttachment = new Attachment();
        objAttachment.Name = 'J2S.pdf';
        objAttachment.ParentId = contactId;
        objAttachment.Body = pg.getContentaspdf();   
        objAttachment.IsPrivate = false;
        insert objAttachment;
        return objAttachment;
    }
    
}

LWC JS:

1. Add the api in import...

2. Declare the @api recordId;

3. Chnage in generatePDF({txtValue: editor.value , contactId : this.recordId })
import { LightningElement, api } from 'lwc';
import generatePDF from '@salesforce/apex/DisplayRichTextHelper.generatePDF';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';


export default class LWCPDFGenerator extends LightningElement {

    @api recordId;

    allowedFormats =  ['font', 'size', 'bold', 'italic', 'underline', 'strike',
    'list', 'indent', 'align', 'link', 'image', 'clean', 'table', 'header', 'color',
    'background','code','code-block'];

    //this method will display initial text
    get myVal() {
        return '**Generate PDF using LWC Component 2 **';
    }

    attachment; //this will hold attachment reference

    /*This method extracts the html from input rich text 
        and pass this to apex class' method via implcit call
    */
    saveAsPdf(){
        const editor = this.template.querySelector('lightning-input-rich-text');
        //implicit calling apex method
        generatePDF({txtValue: editor.value , contactId : this.recordId })
        .then((result)=>{
            this.attachment = result;
                console.log('attachment id=' + this.attachment.Id);
                //show success message
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Success',
                        message: 'PDF generated successfully with Id:' + this.attachment.Id,
                        variant: 'success',
                    }),
                );
        })
        .catch(error=>{
            //show error message
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error creating Attachment record',
                    message: error.body.message,
                    variant: 'error',
                }),
            );
        })
    }
    
    /*
        This method updates the selected text with defined format
    */
    handleClick() {
        const editor  = this.template.querySelector('lightning-input-rich-text');
        const textToInsert = 'Journey to Salesforce'
        editor.setRangeText(textToInsert, undefined, undefined, 'select')
        editor.setFormat({bold: true, size:24, color: 'green', align: 'center',});
    }
}

In XML File:
 
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
    </targets>
</LightningComponentBundle>

Thanks,
Maharajan.C