New answers tagged

0

The issue is almost certainly due to the callback function on setInterval not having "this" bound to the LWC component instance: setInterval(function () { getNotifiche({recordId:Id}) .then(res1 => { console.log(res1); this.notifiche = null; this.notifiche= res1; /// this doesn't work }); }....


1

Hi i have used following code - APEX Class - @AuraEnabled(cacheable=true) public static Date getDate(Date dt) { System.Debug('dt '+dt); return dt; } and JS Code - @wire(getDate,{dt:"2019-12-31"}) date({data}) { if(data){ console.log("Data"+JSON.stringify(data)); } } or @wire(getDate,{dt:new Date("2019-...


2

The first thing is your apex method return value is wrong. Your method expect a string value to return but you are returning a date value. The correct code is:- @AuraEnabled(cacheable = true) public static string apexMethod(Date z) { return String.valueOf(z); } Now, to call it from LWC, You can pass a date object value as parameter from JavaScript ...


0

I found a fix. Lightning and Aura components use Secure Wrappers, so we are not able to use features like getElementsByClassName or getElementById. See more: https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.security_locker_global_access But instead should be used query selectors on shadow DOM: this.template.querySelectorAll('....


0

You can access to shared Data Extensions with the LookupRows function. var dataExtensionName = 'TEST'; dataExtensionName = 'ENT.'+dataExtensionName; var result = Platform.Function.LookupRows(dataExtensionName,'ColumnName','Value'); //Write log output Write('Result: '+Stringify(result)+'<br>');


0

I resolved this issue; The $Lightning.createComponent() function expected the name of the component, not the app (silly mistake). I changed this to the name of the component and now my Lightning Component loads within my localhost.


1

You need to use an if statement: if(confirm('Are you sure you want to cancel?')) { result = sforce.connection.update(updateRecords); top.location.href = url; } The confirm method returns true when the user clicks OK or presses the Enter key, and false when the user clicks cancel, the X button, or Escape.


1

I see the issue. You currently have this in your Aura App: <aura:application extends="ltng:outapp" access="global"> <c:CommunitiesDayExternal /> </aura:application> It should be this: <aura:application extends="ltng:outapp" access="global"> <aura:dependency resource="c:CommunitiesDayExternal"/> </aura:application&...


0

If you are willing to wait until at least Summer '20 for GA, you could use Ligthing Message Service.


2

Your not setting the value attribute for your options, it should be below format [{ value: "abc", label: "ABC" },{ value: "xyz", label: "XYZ" }] your Name value is not existing in to your options that's why it's not selected default, in your below Json data Acme is not existing options(Acme not equal abc/xyz). { "data": {"Name": "Acme","Age": "34","...


1

The items variable's reference is indeed not altered. Consider pushing the items to a separate variable and assign it to your items variable later. Pseudo code: let mappedItems = []; results.map(result => { mappedItems.push({label: result.label, value: result.value}); }) this.items = mappedItems;


0

As far as i am concerned, the @track property rerenders when the value changes, in your case, data is an array, so if you sort it or add some elements using array.push() for example, the var value itself does not change as it is a reference. Try using this statement after the for where you fill the items array: this.items = JSON.parse(JSON.stringify(this....


0

I finished working on something related to this recently. I wrote a small Apex Wrapper-ish class that will grab all the writeable fields for a declared SObjectType, and compare them with the already included values in our currently instantiated records list. (My utility doesn't query for additional field values, it just makes the existing records include all ...


2

Without seeing your code, it'd be hard to tell why this is happening. The most important thing to remember is that events cannot be processed until your code stops executing, so you should do something like this: handleClick() { this.dispatchEvent(new CustomEvent('showspinner')); setTimeout(this.continueProcessing.bind(this), 0); } ...


0

What i did is added the proxy configuration in 2 JAVA files : 1) EmpConnector.java public EmpConnector(BayeuxParameters parameters) { this.parameters = parameters; httpClient = new HttpClient(parameters.sslContextFactory()); ProxyConfiguration proxyConfig = httpClient.getProxyConfiguration(); List<ProxyConfiguration.Proxy> proxies = ...


0

I found the answer to this by relying on JavaScript as opposed to just JQuery. Adding the onClick right on the commandButton worked with JS but I was breaking my head trying to make it work with JQuery. I'm no expert so I don't know the why, but I'm very happy that it works. <apex:column headerValue="Select"> ...


4

you need to make this call from the connectedCallback() method. doing so will have resolved your import by this time. See below: import { myfunction } from 'c/reusableLWCFunctions'; export default class myLWC extends NavigationMixin(LightningElement){ connectedCallback(){ myfunction('THIS WAS CALLED FROM IMPORTED FUNCTION'); } } the ...


0

Even though i don't query the Theme__c Id it gives it to me anyways. This happens by default. Queries return ID automatically. Now when i console log dataParse outside of the loop i get this Because that's the code you wrote. You're replacing the contents of dataParse each iteration of the loop, so by the end, you only have the last element. Instead, ...


2

There are two ways for this. HTML Way: I will explain with your wired property record.data. Let's say there's a field Contact_Name__c. You can add checks like below. <template if:true={record.data.Contact_Name__c}>{record.data.Contact_Name__c}</template> <template if:false={record.data.Contact_Name__c}>No Contact</template> You ...


0

You cannot make read-only the status field to Community Users and any other profile as well as you cannot remove it from a Page layout. One Way is that you can write a validation rule based on the Community User profile and restrict that user from changing the value. The validation rule can be something like that. ISCHANGED(Status) && $Profile.Name ...


-1

Sample code, creating a class outside of the lightning elements class is the easiest way import { LightningElement, api, track, wire} from 'lwc'; import { NavigationMixin } from 'lightning/navigation'; import findFiles from '@salesforce/apex/fileFoldersClass.findFiles'; class blah { constructor(tett,ugh) { this.tett = tett; this.ugh=ugh ...


1

You are almost on it. While making your 'preparedAsset' object you are using the name of the list 'preparedAssets' instead of 'preparedAsset'(object variable name) Replace your object creation code with below one:- this.data.forEach(asset => { let preparedAsset = {}; preparedAsset.Id = asset.id; ...


6

Javascript is case SEnSiTivE. You have defined variable in apex as monthListBefore but in JS you are trying to access MonthListBefore, which does not exist. So, Try this.MonthList = data[0].monthListBefore;


0

Below is my standard sort algorithm for a LWC. I hope this helps. @track sortBy @track sortDirection @track data handleSortData(event){ this.sortBy = event.detail.fieldName; this.sortDirection = event.detail.sortDirection; console.log(event); this.sortData(event.detail.fieldName, event.detail.sortDirection); }; ...


2

There is some coding involved to get this running but you shouldn't need to start from scratch. You'll need to update your columns array so that at least one column is sortable ("sortable": true), then set the sortedBy attribute on your datatable with the name of the column that the table is sorted by when the component loads. From the lightning-datatable ...


0

I also was unable to make this work, from the code that was provided as my base. So I went a different route that does a decent job and is supportable. <apex:page controller="test" docType="html-5.0" lightningStylesheets="true" language="{!language}"> <apex:form> <select id="...


0

findLocation({ locationName: location }).then( result => { console.log(result); this.locationName = result; this.showSpinner = false; }, error => { //this.showSpinner = false; console.log(error); } ); Referral Link : https://salesforceblog.tumblr.com/tagged/lwc


1

As per documentation localizationService supports only ISO 8601. The date parameter can be a String, Number, or most typically a JavaScript Date. If you provide a String value, use ISO 8601 format to avoid parsing warnings. 31/12/2019 is not as per ISO 8601 format. You either need to convert that to the supported format or a valid Date object in JS....


0

I was able to do it using postMessage. When I tried before I did not have the "*" as the domain parameter and that was blocking me. I added this to the JS Button window.addEventListener("message", receiveMessage, false); function receiveMessage(event){ if( event.data === "close"){ window.parent.sd = null; //Needed due to current code. ...


0

The best way to do this is is not on every VF page, but rather by using a customized login flow to detect the user's browser at point of entry to Salesforce. Use Visualforce and an Apex controller to create a custom login flow programmatically. With Visualforce, you have complete control over how your login page looks, behaves, and where users go after ...


0

You can have script in the visualforce page which runs on page load where you can check the browser <script> var previousOnload = window.onload; window.onload = function() { var objbrowserName = navigator.appName; //logic console.log('====objbrowserName===',objbrowserName); } </script> this works respective to the page.


1

By default, a ContentVersion is added to a private library and when attempting to link an object to the newly-created ContentDocument you will get the error in your Post. Use the code below that defines the library as per ContentVersion object documentation FirstPublishLocationId Create, Filter, Group, Nillable, Sort Description ID of the ...


2

You can create your own wait function with for loop and a break. See my blog post for more details. Sample wait function: <script runat=server> function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds){ break; } } } sleep(1000);...


0

I believe this error is tied to the Apex controller reference on the lightning component. When I encountered this error it was because I was attempting to push an aura lightning component with a change set and I did not include the Apex Controller. Adding the Apex class to the change set fixed the deployment error.


1

Check out this playground to get an sample example of Number field with a predefined value in Lightning Web Component. value property of lightning-input component specifies the value of an input element. Reference:- Lightning Web Component Input if you are dealing with Lightning Data service and want to pre-populate the field value of lightning-input-...


1

According to SF documentation, it is possible to be done without placeholder, just put default value in value field: <lightning:input type="number" name="input2" label="Number field with a predefined value" value="0.0"/>


1

Instead of providing a public library id in FirstPublishLocationId field of contentversion object, You can just pass the parentId of the custom object you are trying to associate the file with. var attachment = new sforce.SObject('ContentVersion'); debugger; attachment.Title = getFileName(filename); attachment....


3

Short answer: you can't. The jsconfig.json file exists to help the IDE identify Javascript project directories to aid with code-completion mechanics. For example, a supported IDE might offer suggestions of other js modules when writing an import statement in another js module inside a directory with jsconfig.json in the root directory. In addition to this,...


1

I'm not familiar with where you found jsconfig.json. But you can only import files that are uploaded to the org. Your file is only part of your File System and not Salesforce Org. I would suggest the following options. Create separate file in component folder // data.js export default const data = ['comp1', 'comp2']; // component.js import data from './...


0

This is X-Y problem question. Actually, instead of making tweaks for mass check checkboxes on standard layout, one can just invent and publish an AppExchange package with header checkbox functionality where admin user can click checkbox in a header row to check all checkboxes. I have just released recently a package called BofPerMan which gives a ...


Top 50 recent answers are included