Salesforce Lightning

KeyCode of a key pressed in Lightning Web Component

There will be a scenario where you need to identify if Enter is presses or any special character is pressed. Below code will demonstrate how to identify a keypress code. In Lightning Web Component.

For this scenario we need to add a span section with onkeypress event above the input text field. And call a JS method. Something like this.

Continue reading “KeyCode of a key pressed in Lightning Web Component”
Salesforce Lightning

Toast Message in Lightning Web Component

It is always a good practice to display a toast message so that users are aware of what is happening in system. A toast message can be show to user when you want to show a Success message or an Error message or a Warning message. Toast message is simple to write and very effective.

In this blog we will see all 3 ways in which we can display a toast message. A toast can also simply provide information. To display a toast notification in Lightning Experience or Lightning communities, import ShowToastEvent from the lightning/platformShowToastEvent module.

When you dispatch an event to show the toast message you need to know few properties that are used in toast message.

Continue reading “Toast Message in Lightning Web Component”
Salesforce Lightning

Calling Apex Method with Parameters from a Lightning Web Component

There will be ample scenarios where a developer must customize things in salesforce to meet the business requirement. Customization in Lightning Web Component (LWC) can be done in multiple ways based on requirement. One is using lightning-record-edit-form and lightning-record-form. With these developers will have very minimal control over the component. Another way is by calling a server-side method. With this, developers will have good control over the component and can achieve complex business requirement. In this blog we will see how we can call a server Apex Method with parameters from an LWC JavaScript(.JS) file.

There are few things to note when you want to call an apex method.

  1. Importing the Server-side method (apex class).
  2. Calling a Server-side method from JS method.
  3. Fetching the value that is returned.
Continue reading “Calling Apex Method with Parameters from a Lightning Web Component”
Salesforce Lightning

Lightning Web Component using lightning-record-edit-form

<lightning-record-edit-form />

Use the lightning-record-edit-form component to create a form that’s used to add a Salesforce record or update fields in an existing record. If you need a solution with custom screen, you need to use this tag. Whole layout need to be customized. The component displays fields with their labels and the current values, and enables you to edit their values.

lightning-record-edit-form supports the following features.

  • Editing a record’s specified fields, given the record ID.
  • Creating a record using specified fields.
  • Customizing the form layout
  • Custom rendering of record data.

If there is no customization required then you can go ahead with <lightning-record-form /> tag for development.

Continue reading “Lightning Web Component using lightning-record-edit-form”
Salesforce Lightning

Lightning Web Component using lightning-record-form.

<lightning-record-form  />.

To Create, Edit and View a record “Quickly” you can use “<lightning-record-form />”  tag. Salesforce automatically Loads all fields in the object’s compact or full layout, or only the fields you specify. There is no manual custom field tag that user need to add and customize the layout. Salesforce handles everything for you including the lookup fields.

Overall if you are looking for a quick solution to create a record instantly, you can go with <lightning-record-form />.  

Every tag comes with some attributes. For this tag there are few important attributes that are usually used.

  1. object-api-name
  2. fields
  3. record-id
  4. layout-type 
  5. mode
  6. record-type-id

There are few more…

Continue reading “Lightning Web Component using lightning-record-form.”
Governor Limits · Salesforce Lightning

Introduction to Lightning Web Component and Basic Applications for LWC

As I mentioned in my previous blog(Introduction to Lightning Aura Component), Salesforce supports 2 different programming modules.

  1. Lightning Aura Component (LAC)
  2. Lightning Web Component (LWC)

Since LWC is a big topic we will cover just introductory part in this blog. So the question is –

What is Lightning Web Component (LWC)?

Continue reading “Introduction to Lightning Web Component and Basic Applications for LWC”