New answers tagged

0

Q1 When an account is inserted or updated,check whether any opportunity is linked to it or not, if not then create one whose name is 'First Opportunity - trigger AccountAssignment1 on Account(after insert, after update) { List oppList = new List(); // Get the related opportunities for the accounts in this trigger Map<Id,Account> acctsWithOpps = new ...


0

Get the Sum of Amount of all closed opportunities owned by the current logged in user. The Sum should be displayed for every fiscal year by a single query public class SOQLSOSL_Assi1 { public static void main() { /* * Get the Sum of Amount of all closed opportunities owned by the current logged in user. The Sum should be displayed for every ...


0

How to create lwc components to print the account details in pdf


0

Hello rffjh vchgg hhfddfjfxddnhzdsdhjgszfhjfxxvjhdxghfxchgddfjvffxgjjhcvhhf


0

You can create a listener inside your LWC component and fire a message from Aura. For this you can either use LMS or window.dispatchEvent


1

Show us the LWC code if possible, but just FYI LWC is template based, where <script>, <html> , <head> tags does not make sense. Check here If you still want this same code in LWC then you can do this workaround. Create a VF page, dump your code there, and host the VFPage as an iframe in LWC. LWC: <template> <iframe src="/...


0

In lightning, I had to do this to retrieve the recordId ({ doInit : function(component, event, helper) { var pageReference = component.get("v.pageReference"); console.log('pagereference = '+pageReference); if (pageReference){ console.log('pageReference exists'); console.log('pagereference.state = '+...


0

This is how LWC or as a matter all Lightning components work. Your code works fine. I created a button to check and it gave correct xxx @track historyData = [] connectedCallback() { this.pushToHistory(); } pushToHistory() { var item = {}; item.id = 'a'; item.data = 'xxx'; this.historyData.push(item); } handleButtonClick() { this....


0

try using lightning-record-edit-form. it will automatically refresh the form when you hit save.record edit form


0

I guess you are using lightning-input-field inside lighting-record-edit form. here date format is automatically validated against the user's Salesforce locale format.


0

I tried below code and got the required output. JS: import { LightningElement ,api,track,wire} from 'lwc'; import { getObjectInfo } from 'lightning/uiObjectInfoApi'; import CAMPAIGN_OBJECT from '@salesforce/schema/campaign'; import RECORDTYPEID from '@salesforce/schema/campaign.RecordTypeId'; const _FIELDS = [RECORDTYPEID]; import { getRecord,getFieldValue }...


0

I ended up using a Platform Event and setting up the channel in the LWC component to refresh Apex when new message is received. Also added a refresh button to do the same. Small excerpt of the code. // For refreshing Apex result; channelName = '/event/Some_Event__e'; connectedCallback() { this.handleSubscribe(); } disconnectedCallback() { this....


2

In LWC if you are trying to do a callout use fetch like this. let endPoint = "https://dummy.restapiexample.com/api/v1/employees"; fetch(endPoint, { method: "GET" }) .then((response) => response.json()) /* response.json() gives us back a promise we need to process the promise in .then()*/ .then((repos) => { this.repos =...


1

I found the same thing. I have a quick action calling an aura wrapper using QuickActionWithoutHeader. It encloses a lightning web component. I fire a toast from the LWC when a button is clicked in the LWC. When the toast closes (timed out or close box on toast banner clicked manually) the following error appears in the javascript console: icon.js:110 ...


5

For a given name, you either have a property OR you have a get (and set) function, never both because as you see the LWC processing will be messed up. That's because of how JavaScript's property getters and setters work. You define a property using an appropriate name. But if you define a getter or setter you are re-defining that property to be handled by ...


2

I may be wrong here, as I have never worked on communities, but how was .myAccount{ display:none; } working before. When i inspect element in my community page, i see each menuitem written as home uiMenuItem, profile uiMenuItem. Though I cannot see My Account as I dont have certain permissions. But I went ahead and from advanced setting of community builder ...


0

To bubble an event from a child to a grandparent, set bubble: true. (Use the default value for compose, which is false.) This configuration bubbles the event up the DOM, but doesn't cross shadow boundaries. The event is visible only in the template that contains your component. You can see examples in the LWC Dev Guide and in the EventBubbling recipe in lwc-...


0

Take a look at this link: https://github.com/salesforce/lwc/issues/1666 A case was opened to Salesforce support related to this issue and their reply was that extending another component aside from LightningElement is not currently supported in LWC's due to Lightning Locker Service preventing the extension. That is a bit missguiding from their side though, ...


2

I would recommend just using papaparse. Once imported, you can have the list of objects returned from the wire call and passed directly into Papaparse, which will output a CSV for you. let csv = Papa.unparse(accountData); Since you're already using D3, I presume you're familiar with importing scripts to LWC. All you need is a bit of help, and that library ...


0

You can address this by adding an identifier API property to the LWC and define this as a target config property in the LWC's metadata file. As long as the admin sets these identifiers uniquely for each use of the LWC you have a means to know exactly which instance of the LWC needs the "primary" file details. The myLWC.js: export default class ...


0

The productId must be defined as the property in the LWC component. You can define that in two ways. A Define the attribute. import addasFav from '@salesforce/apex/ProductController.addasFav'; export default class ProductTile extends LightningElement { productId; // asign some value later. foo(){ ... this.productId = somevalue; } ...


1

Yes, you can do that, but you can't set that from HTML code. You need to set that from JS controller. You can do it using a for loop or map function. Also, you can define a custom attribute instead of Id. this.questions = this.questions.map(question => { return { ...question, uniqueName: question.Id + 'Somevalue' } })


2

LWC does not support expressions like that. (here) The engine doesn’t allow computed expressions. To compute the value of expression, use a getter in the JavaScript class. You need to do the concatenation in js and then push it to template.


0

if you want to call the Visualforce page javascript function from LWC then it is useful for you. Notice: LWC must be placed within the VF Page. In your visualforce: document.addEventListener("customevent", function(event){ callvffunction(); //do your vf stuff here }); In your LWC : somelwcfunction = (event) => { const customevent = ...


1

For Aura, use: <aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride"> Note: it is not possible to actually override using LWC (for now), use an Aura wrapper, such as demonstrated in this demo by Andrew Fawcett. In both cases, you'll be able to read recordId via the usual methods: // Aura ...


0

I was able to get this to work. For posterity... Create an @api-decorated function in your Lightning Web Component, like this: @api addEvent = event => { this.events.push(event); }; In Visualforce, the $Lightning.createComponent() callback function gets an argument, which in these docs is called cmp. cmp is an object with a property called ...


1

Yes cometD is the way for VisualForce Page. And to communicate from VF page to LWC you can use postMessage. (Posting a message from VF Page and listening in LWC). Also there is a Lightning messaging channel in salesforce which communicates in different domains, but I have not tried that. But I know for sure postMessage works without any issues, even if the ...


1

I initially assumed, given that you're sending back a Map<String, Object>, the parser is not intelligent enough to try to map an Object to the appropriate type. Couple that with not all Apex primitives being given a representation in JSON (Dates and DateTimes for example are ISO timestamps as strings) and you're going to run into some limitations ...


1

Remove the .value.id from the selector, that would return the actual DOM element from the selector, with that you can call the appropriate validity method. let lookupCmp = this.template.querySelector('c-lookup-lwc[data-class="validateinput"]'); lookupCmp.setCustomValidity("Manufacturer value is required"); lookupCmp.reportValidity(); If ...


0

If you are using your lightning component on lightning record page, You can use record-edit-form which create a form that's used to add a Salesforce record or update fields in an existing record on an object. It has an attribute called record-id. If it has value, it will load the record else it will allow you to create record. look into a sample example: - ...


0

This might have to do with locker-service in which it prevents any dom modification, and seeing the library, it will definitely modify the dom. Check this : https://developer.salesforce.com/docs/component-library/tools/locker-service-console. Copy your js and paste it here and check if the library is able to access all the required APIs. As a workaround if ...


1

When you set { fieldName: 'someFieldName' }, it doesn't show the text, instead it shows the dynamic value from the data instead; in other words, it wouldn't show Show this text in a tooltip, because you're telling it to show a field value. This causes it to revert back to what a URL shows by default, being the label. To show a literal value, use a string: { ...


-1

Adding to the answer: .selected-pill { --sds-c-pill-color-background: var(--lwc-brandPrimary); }


2

The beauty of using the lightning-record-edit-form component is that you don't need to worry about the types of any of the fields. Using lightning-input-field inside of the component is enough - Salesforce will handle the rest and show the appropriate UI based on the type of the field. For example, a combo box for a picklist, an input[type="text"] ...


0

You should be able to do something like this: workspaceAPI.getFocusedTabInfo().then(function(response) { var focusedTabId = response.tabId; workspaceAPI.closeTab({tabId: focusedTabId}); }) .catch(function(error) { console.log(error); });


0

If you are running into this error in the Trailhead module: Salesforce trailhead LWC Testing Running npm install @salesforce/sfdx-lwc-jest@prerelease --save-dev in the VS code terminal worked for me. I believe there is a lag time between when Salesforce releases their versions and when the project.json file gets updated for npm. Updating to the prelease ...


1

document.title still works fine, the issue is it gets overriden by the record name if the lwc component is on a record page, rest for an app page it works fine. So you can try giving it a timeout if its a record page. connectedCallback() { setTimeout(function (){ document.title = 'Test Me Please'; },10000); } Or just try by removing the ...


0

As onsucess is being called in your code, adding refresh component in onsucess function would definitely work. Calling the refresh component onsubmit would be too early and would not provide you exact results. handleSuccess(event) { console.log('Record Id ' + event.detail.id); const evt = new ShowToastEvent({ title: "Metric ...


0

Create a validation rule and the lightning-message will auto show the validation message.


1

The error you are getting is because you can access only @api properties in the jest test context. Everything that is marked @track or the @wire is going to be not defined in the test context. You should just test the DOM elements that have rendered fine with the proper number of elements instead.


1

Jest ships with the jsdom and you can see that the dataTransfer is not yet implemented and hence you are receiving the error below TypeError: Cannot read property 'setData' of undefined The undefined here is the dataTransfer object. You can use the jest manual mocks to mock the implementation of dataTransfer as shown below. Note how I have used the object....


0

Looks like you have a typo in your event. Try changing dropRowEvent to "myCustomEvent" and retest. import LightningDatatable from "lightning/datatable"; export default class LightningDatatableExtended extends LightningDatatable { boundHandledMouseUp = this.handleMouseUp.bind(this); constructor() { super(); this.template....


2

Wired invocation needs cacheable as true, but this causes the apex session to be read only. To be able to perform DML you must not use cacheable which in turn means you cannot use a wire. Instead use imperative apex. Check the documentation.


1

The issue is you are trying to return an Object and you are trying to iterate over it. I was able to replicate this via this code: connectedCallback() { const testData = []; const testMe = { value : '123Value' } const testMe2 = { value : '123Value2' } //testData.push(testMe); //testData.push(testMe2); this.data ...


1

It should be @salesforce/apex/ContactController.getContacts, not @salesforce/schema/ContactController.getContacts, which is used to import object and field references.


1

You can use platform event or Generic event ( which will be user specific)' here for your use case. Subscribe to Platform event in your LWC component. https://newstechnologystuff.com/2020/08/15/platform-event-in-lightning-web-components/ Then in the finish method of your batch just publish the platform event notifying your UI that the batch job is finished. ...


1

AFAIK, you cannot have a formatted <a> element inside lightning-formatted-text. However, for your requirement, you can build your own custom HTML completely by using <a> & <p> (or <span>) tags and not <lightning-formatted-text>. A better option would be to use lightning-formatted-url (as shown in the sample code snippet ...


0

According to docs Returning the Record Id LWC documentation, record ID is returned via onsuccess handler. Example given below same as doc. <template> <lightning-record-edit-form object-api-name="Account" onsuccess={handleSuccess}> <lightning-messages></lightning-messages> <div class="slds-m-...


0

Import NavigationMixin and Apply the NavigationMixin to the component's base class.


0

You can use getObjectInfo to get the record types by ID and name. It will require a separate wire call, but once loaded, you'll know the record types by name and ID.


Top 50 recent answers are included