New answers tagged

2

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 recordId = event.target.dataset.oppid; this[NavigationMixin.Navigate]({ type: 'standard__recordPage', attributes: { actionName: &...


0

look heroku node.js with streaming channels https://developer.salesforce.com/blogs/2021/08/how-to-work-within-platform-events-delivery-limits


1

There's a known issue created for this you can follow: Starting with iOS 15 and Safari 15, VF pages using alert, confirm, prompt dialogs will be blocked It's still not 100% clear whether it'll go live with the initial release or if Apple will hold it back similar to how Chrome ended up doing (pushing it back to a later date).


2

You can use "Promises" to control the flow. Following are few links where you can find some examples. The goal is to do something like this : var action = cmp.get("c.fetchServerData"); new Promise(function(resolve, reject) { action.setCallback(this, function(response) { //check the state and do stuff }); ...


2

the map function returns an array of objects, instead of assigning values within the map, you should assign the result of the map to your variable as follows: this.optionsTemp = result.map(element=>{ return {value: element.fieldValue, label: element.fieldLabel}}) if you need to merge the result of the map with what is already in ...


0

You need to keep track of all previous selections in a separate variable. I wrote this quick demo that shows how to do this. Here's the controller: import { LightningElement } from "lwc"; export default class App extends LightningElement { // All existing rows allData = [] // All selected Id values allSelectedRows = new Set() // Current ...


0

You need to make sure that input.value is not undefined. from your code, there is no indication that picklist-group-label exists. hence the input.value returning undefined. same goes for your txtValue variable. couple of comments: why aura? and not lwc. as per your "approach" to search, I would strongly advise against using the hide and display ...


3

I don't know for sure, but I imagine you're attempting to edit the html content of <span id="gauge-value" style="font-size: 15px;"></span>, but you haven't set lwc:dom="manual" on it. Not sure why you're trying to directly manipulate the DOM for this. I'd try replacing <span id="gauge-value" style="...


2

RTCPeerConnection is not supported by Lightning Locker From Winter '22 on, you can activate next generation Lightning Web Security for LWC (beta) and see if that specific interface is supported (haven't tried). See more details here.


-1

Not possible inside salesforce using apex/javascript because you will have to run that on load of the page. You cannot customize something like onload property on a dashboard page. A hack : In outlook create a distribution list and add all the users emails to that distribution list Create a user in SF with email as the email of the distribution list ...


1

In Aura, you have expose methods via aura:method, then call them using an instance of the component. You can't just create a new class like that and have it work. <!-- saveAccount.cmp --> <c:spinner aura:id="spinner" /> // saveAccountController.js someFunction: function(component, event, helper) { component.find("spinner")....


0

You can create a LWC only with the XML by default and the JS. In the JS you export what you want, for example: export function getQueryParameters() { ... } export function whateverFunction(){ ... } this LWC is called jsUtilities, and the code only has this functions. Then, when you want to import, you have to use the syntax like this: import { ...


0

Could you please try export Calculator { static add = (a, b) => a + b; } without the default/class keyword. Worked for me.


1

You can’t simply take any JS and run it as SSJS. Since you will be running it server side, the code will only be executed once, when the page loads. If you need to do anything which relates to capturing events happening client side (like a checkbox changing state), you should not set runat=“server” attribute


4

You're trying to parse the element name, instead of its value, and if you try to parse a string like 'firstNumber' into an integer you'll get NaN. You should also change the type of your lightning-input to number, integer isn't a valid value. The documentation lists every valid one. Anyway since the default step is 1, only integers will be valid values. You ...


1

Assuming it needs to be JavaScript, just add a CSS rule: CS.EventHandler.subscribe(CS.EventHandler.Event.AFTER_SHOW_SCREEN_ACTION, function (payload) { //? Test functionality... document.styleSheets[0].insertRule("#addonman { display: none; }"); }); By adding it as a rule, you can technically do it whenever you want, even before the button ...


0

Try this: ROUND(Value * 2)/2 Example: We want 5.3 to become 5.5 5.3 * 2 ==> 10.6 Round(10.6) ==> 11 11/2 ==> 5.5 Floor and Ceiling also work with this method. We can even make work with 0.25 values. We just multiply by 4. Example: make 5.3 as 5.25 5.3 * 4 ==> 21.2 Round(21.2) ==> 21 21/4 ==> 5.25


0

Use onbeforeunload to handle this situation: window.addEventListener( "beforeunload", (event) => ( event.preventDefault(), (event.returnValue = "Are you sure you want to leave?") ) ); However, the user will always still have a choice to leave or not. You cannot force them to follow your rules. Your app must be prepared ...


0

This is probably happening because when your component initially renders and invokes StageLabel, and this.oppInfo still hasn't retrieved the data from the wire method. you can add a type check to your properties or check the properties in the chain to ensure that they are not undefined before rendering by using Optional chaining (?.) example: this.oppInfo?....


1

You can create a reactive component by using the lightning emp api The lightning/empApi module provides access to methods for subscribing to a streaming channel and listening to event messages. All streaming channels are supported, including channels for platform events, PushTopic events, generic events, and Change Data Capture events basically, if you ...


1

For a normal input field, just set value directly: this.template.querySelector('lightning-input').value = this.number Or, you can bind that value directly to the input: <lightning-input type="number" value={number}></lightning-input>


3

Id values are modified by the runtime in order to be globally unique. Do not use id for any purpose whatsoever, it may be unreliable. Instead, attach a data-* attribute to your data: <lightning-input data-id={invoice.Id} ...> </lightning-input> (Remaining attributes omitted for legibility) Then you can read it in your handler: var id = event....


2

Considering that you have deeply nested properties when assigning values, you might want to ensure that they are not returning undefined. to ensure that the properties in this.quote.fields.Order_Bill_To__r.Comm_Model__c.value populated. I would suggest you use a combination of Nullish coalescing operator (??) and use Optional chaining (?.) Ex: this.quote?....


0

Your problem is you are only taking one value at a time, as target is only containing the current checked or unchecked box. itemsToFitler = []; handleCheck(event){ let v = event.target.value; if (event.target.checked) { this.itemsToFitler.push(v); } else { const index = this....


2

I personally recommend using await/async, as it's far easier to read: try { const response = await fetch(URL_FORCE_FUNDS, { method: 'POST', headers, body: urlencoded}); console.log('Here is the Data from Server == '+JSON.stringify(response)); if(response.serviceStatus == 'ERROR') { this.showToast('Error', response.data.errorMessage,'Error'); ...


1

You are trying to use something like this: IN :idsSet, it is definitely allowed only in Apex, you need to concatenate ids in your variable to a string somehow like this: "IN ('" + idsSet.join("', '") + "')"


3

this looks like is an error on this evaluation as @Damecek suggested. I also suggest using arrow functions for this: fetch(URL_FORCE_FUNDS, { method: "POST", headers: headers, body: urlencoded }) .then((response) => { console.log('Here is the Data from Server == ' + JSON.stringify(response)); return response.json(); }) ...


1

in your wired method getTargetRecord you might want to ensure that data.fields.Target__c.value is not returning undefined. there are several ways of doing this: 1.- undefined check using typeof 2.- Nullish coalescing operator (??) 3.- use Optional chaining (?.) to ensure that when you load the chart loadChart those values are populated. You can always opt to ...


0

I was able to solve this problem without the need of JQuery, and I was also with the need of a disabled button. I just called a window.onload function calling the button id as disabled and everything worked fine. It is something like: window.onload = function() { document.querySelector("[id$='submitBtn']").disabled = true; };


0

you might want to refer to the documentation: Access Elements the Component Owns Don’t use the window or document global properties to query for DOM elements. See DOM Access Containment. Also, we don’t recommend using JavaScript to manipulate the DOM. It's better to use the Lightning Web Components HTML directives to write declarative code. in a nutshell, ...


3

This is a job for Array.reduce: let result = arrnav.reduce( (p,{iaId,name,age}) => (p[iaId] = { name, age }, p), {} ) There's a lot to unpack here, so let's take a look. Array.reduce(callback, initialValue) We start with a function, Array.reduce, that takes two parameters, a "callback" (a method to call for each item) and an initial value. ...


0

Creating a child component and passing values down is definitely one of many approaches you can use, another approach can be to "restructure" or modify your json to include all the necessary metadata to iterate over the properties as follows: from: this.tempData = [{ 'field1': 'name', 'field2': 'type' }]; this.fields = ['field1', 'field2']; to: ...


0

For your specific use case, you could: Object.assign(this, getParameters(mode)); Object.assign accepts two or more parameters, identified as (target, ...sources). The pseudo-code for this method looks like: function assign(target, ...sources) { for(const source of sources) { Object.entries(source).forEach(value => (target[value[0]] = value[1])...


1

You are close. querySelector('lightning-record-edit-form') will get you only the first form. querySelectorAll('lightning-record-edit-form') will get you a list of forms where you cannot call the submit method. You need to iterate this list and call submit 1 by 1. Something like this. this.template.querySelectorAll('lightning-record-edit-form').forEach((form) ...


0

I was able to resolve with one simple changes. Specify the property-names from object and assign its value to global variable on the left hand side. And enclose the entire answer in parenthesis. ({count:this.count, moves: this.moves} = getParameters(mode)); So, this.count & this.moves gets the value of count & moves respectively. If, you have any ...


3

The reason why this happens, is that updating the child's @api property within the child doesn't inform the parent of the change (it still thinks that open is false). Consequently, when the parent's cityList notices it has been changed, it causes a render cycle, which compares the old values that were in cityList previously to the new values that are in ...


1

There's no need to use ID values here, just use event.target: <apex:inputfield required="true" onclick="getEmail(event)" value="{!IBI_TM_Applicants__c.Email_ID__c}"> function getEmail(event) { var email = event.target.value; // ... rest of code


2

You can simplify your code by using the optional chaining operator (?.) which enables you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid. additionally, you can use a nullish coalescing operator (??) at the end of your chain to assign a default value if the ...


2

From what it looks like, process.env.PORT is interpreted as a string then adding +1 concatenates the value, and then gets translated to an integer, this might be causing the issue. Ex: '35025' + 1 = '350251' which coincides with the out of range port number. you should not be adding +1 to the port number variable


0

Can you try to create an array with each urlfor and use it on your reference to the icon? See below: Add to your page: var icons = { 'icon1': "{!URLFOR($Resource.ChartsIcons, 'icon1')}", 'icon2': "{!URLFOR($Resource.ChartsIcons, 'icon2')}" }; ... On your reference you can use the indirection: L.icon({iconUrl: icons[iconName], ...


1

You can use the ::placeholder pseduo-class: <style> .subscriptionNumberInput::placeholder { font-size: 50%; } </style>


0

there is a way more simple, just put a field data as the toggle: typeAttributes: { iconName: 'utility:upload', name: 'upload', disabled : {fieldName :'uploaded'}, iconClass: 'slds-icon-text-success' }


1

With lwc.dev/guide/light_dom#enable-light-dom that worked!


1

this won't be set from an external file, so you'd have to pass in the component to use: onclick() { showToast(this, 'title','message','severity') } ... export function showToast(component, title, message, severity) { const evt = new CustomEvent('toastevent', { bubbles: true, composed: true, detail: { title: ...


0

fetchData is simply an example method used in the doc, indicating that you should define a method to "fetch more data". Basically, you need handle the "fetching data" part with your own function.


2

The important thing is to make sure you capture the keypress at the right place in your DOM hierarchy, e.g. on the section, using something like onkeyup={keyboardHandler} and do something like the following in the callback function: keyboardHandler(event) { event.stopPropagation(); if (event.key === "Escape" || event.key === "Esc"...


2

It looks like you are attempting to pass down a function, not a value, to your child LWC. instead of: // Parent LWC getchecboxDataforChild() { console.log('chkdata= ', Object.keys(this.chkboxObjDatafrmParent)); this.chkboxObjDatafrmParent = { headervar:this.labels.somelabel }; this.template.querySelector('c-generic-checklist').chkboxObjData = ...


2

instead of passing a method getchecboxDataforChild pass the property chkboxObjDatafrmParent


0

As soon as page loads query the data with SystemModStamp and keep it in local variable or pass it along with your data to Client side. When doing DML, just before doing a DML pass this data back to server side(Apex) and query the SystemModStamp again. If it matches then no one has changed the data. If not then someone has updated the data and throw error.


1

It took a bit longer than strictly necessary to discover the problem, as the script's problem is generated as a Warning, not an Exception. aura_proddebug.js:56717 WARNING: Failed to load script at /resource/zingchart: Cannot assign to read only property 'JSON' of object '[object Object]' [Cannot assign to read only property 'JSON' of object '[object Object]'...


Top 50 recent answers are included