Hot answers tagged

5 votes
Accepted

I'm using for-each loop and want to highlight a single row in LWC using onmouseover but only the topmost row in the loop is getting highlighted

querySelector gets only the first matching item. You probably want: addColor(event) { event.target.classList.add('highlight'); } removeColor(event) { event.target.classList.remove('highlight')...
user avatar
  • 434k
4 votes
Accepted

For each in HTML not working

It looks like your variable references are not quite right. Please use different variable names for each reference to avoid confusion. Existing: There is no rn nor rn.contracts. <tbody> <...
user avatar
3 votes
Accepted

How to create dynamic URL for a list of records in LWC

You will have to use a combination of data-* attributes and the standard navigation event. <a onclick={handleClick} data-oppid={opportunities.Id}> ... </a> handleClick(event){ const ...
user avatar
3 votes

I would like to disable a custom button once after clicking it in LWC?

Boolean values, like disabled, can be set to true or false. When true, they act as if they are present, and when false, act as if they are not. Example. import { LightningElement } from "lwc"...
user avatar
  • 434k
3 votes

Row Number column is not getting disappeared in LWC data table

show-row-number-column is forced on if you use inline editing, as per the documentation. By making a column editable, the show-row-number-column attribute is always true and the number column is ...
user avatar
  • 434k
3 votes
Accepted

Disable save button when save is executed

I am still learning the lwc. :) But let me give it a try.Define a boolean variable called as isSaved. Set it to false initially. Change your disableButton method like this: get disableButton() { ...
user avatar
3 votes
Accepted

How to use $Site.Prefix correctly?

$Site.Prefix returns the URL with the preceding / on it, so in your case it returns /portal. Your conditional uses just portal, whereas it should be /portal: <apex:outputPanel rendered="{!$...
user avatar
3 votes
Accepted

Set the color of a value in lwc

You have a few choices. Option 1 is to set the entire style: <div style={style}>{item}</div> Which is set in JavaScript: this.style = `color: ${data.itemColor}`; Option 2 is to set a CSS ...
user avatar
  • 434k
2 votes
Accepted

Why does lightning-input-rich-text add a paragraph tag automatically to the text?

As per case resolution from Salesforce, this is expected behaviour. Here is the gist of SF explanation: The WYSIWYG nature of how our rich text editor displays content only applies to the Lightning ...
user avatar
  • 2,450
2 votes

Setting a max height for datatable in LWC?

I do think that this is an oversight by Salesforce. There is, however, a way to dynamically control the height of the datatable's container div as described in this thread: How to control the height ...
user avatar
  • 53
2 votes
Accepted

Mass String Replacement in all HTML email templates via API

You can work with email templates as with regular records. EmailTemplate et = [SELECT Id, Body from EmailTemplate WHERE id='00X1i000000ljmvEAA']; et.Body.replace('asdf', '1234'); update et; Just ...
user avatar
  • 1,542
2 votes
Accepted

not able to click on slds input icon

Use a button tag instead of span. Below code should work for you <div class="slds-form-element"> <label class="slds-form-element__label" for="combobox-id-3"&...
user avatar
  • 2,619
2 votes
Accepted

Allow child to overflow into parent

I faced this issue recently when using lightning-combobox in a modal, so I replaced lightning-combobox with standard HTML select tag, which overflows into the parent without giving a scrollbar. <...
user avatar
2 votes
Accepted

how to show data of child object records of parent record using lightning-datatable in LWC

The lightning-datatable will not be able to read child records or if you run a query from child to parent the parent fields, In order to do this you have two options, you can either create a wrapper ...
user avatar
2 votes

:last-child selector not working

Your <hr /> needs to be outside the inner <div> for it to be considered the :last-child element, as that selector only considers the last child of the given parent, and, as written in your ...
user avatar
  • 434k
2 votes
Accepted

Lightning Lookup Component - Icon out of Input when having label

For customizing elements as you are, it is recommeded to use the SLDS blueprints and tweak the code/css as needed. example, <div class="slds-form-element"> <label class=&...
user avatar
  • 19.3k
2 votes
Accepted

Updating existing Health Cloud Records on form submission in Cloud Pages

In your first code snippet, you have a fully correct and working code, where you only needed to add the additional field Health_Wellness_Tips__c and value from @opt variable to both ...
user avatar
  • 2,384
2 votes
Accepted

Apex convert &#39 and &quot to apostrophe and quotes

You can use your {!message.value} inside Lightning formatted richtext to resolve the problem. e.g. <lightning:formattedRichText value="{!message.value}"/>
user avatar
  • 5,547
2 votes
Accepted

Problem with "Rendered" in VF Page

You seem to have true and false backwards. The poller will never be enabled, because the default value is null, which is considered false. Further, the default value is null, so the render property ...
user avatar
  • 434k
2 votes
Accepted

How to put footer only from the second page of vfs?

Good people, I got it. I will share the solution that worked for me. I'm developing using a visualforce page but the code can be adapted to html or etc. Set mso-title-page:yes; The leap of the cat is ...
user avatar
  • 255
2 votes

unable to set the first record as selected in html table

If you want to use the radio button, use lightning-radio-group or <input type="radio">. Currently, you are using the checkbox. The main difference is that for a radio group with the ...
user avatar
2 votes

Merged cell in custom table displaying in next column instead of next row

You can use a lightning-tree-grid instead of writing your own component. That reduces your code to simply: import { LightningElement } from "lwc"; export default class App extends ...
user avatar
  • 434k
2 votes
Accepted

LWC div id coming with extra "-0" when loaded in a Salesforce Community

explanation for this is mentioned in the lwc documenration Access Elements the Component Owns Don’t use ID selectors with querySelector. The IDs that you define in HTML templates may be transformed ...
user avatar
2 votes
Accepted

How to add fields side-by-side in LWC (CSS)

Move the lightning-layout outside the iterator, and add the multiple-rows attribute, if necessary. <lightning-layout multiple-rows> <template key={TreatmentWithProducts} for:each={...
user avatar
  • 434k
2 votes
Accepted

How to create a link to a third-party Internet resource in LWC?

Standard HTML tags are always good if you don't need extra features provided by standard LWC components. In your case the anchor element, <a href="URL">...</a>, will be fine.
user avatar
  • 3,418
2 votes
Accepted

How to catch the event of clicking the "Clear" button in lightning-input type="search"?

It's stated at very bottom of the documentation page (emphasis mine) commit The event fired when you press Enter after interacting with the input, or move away from the input so it loses focus. For ...
user avatar
  • 3,418
2 votes

Attempting to use SLDS Examples: are they using JS on the back end?

The SLDS examples are meant to be universally applicable, rather than being tied to a specific framework. This means that translations to a specific platform will be necessary. For Visualforce, this ...
user avatar
  • 434k
2 votes

CSS in LWC - lightning-combobox box to be curved (border-radius)

Use the SLDS styling hook to override the border-radius. Add this code into the .css file of the component. :host{ --sds-c-input-radius-border: 18px; } The above code will be effective for all ...
user avatar
  • 10.6k
2 votes
Accepted

Add Chart to our LWC

Yes, this is generally possible but not easily out of the box. It involves using a charting library and implementing it in LWC. There are ready to use examples by Salesforce Apps on the AppExchange: ...
user avatar
2 votes
Accepted

LWC Array Sorting in Wire

In JS, objects can only be sorted with a sort callback. optionsValues.sort((a,b)=>a.label.localeCompare(b.label)); The function should return -1 if a is less than b, 0 if equal, and 1 if a is ...
user avatar
  • 434k

Only top scored, non community-wiki answers of a minimum length are eligible