I am trying to create a d3 Chart from third party JavaScript file, calling the JavaScript function from Salesforce lightning component on afterScriptsLoaded event.  &lt;ltng:require scripts='/resource/nv_d3_min_js,'           afterScriptsLoaded="{!c.loadD3Chart}" /&gt;   and from loadD3Chart component function I am calling third party JavaScript function for generating the chart.  It's working perfectly fine when I load the page first time but when I come back to the page from another page it's not loading the chart on the page.  ex. In the home page, the chart is working fine but when I go to another page suppose Opportunity page and then come back to the home page by clicking Home menu, that time the third party JavaScript function is called but chart is not loading on the page.  I am new in Salesforce Lightning.
122028
I have a requirement where I use  in Lightning and I have implemented the same as below code. I created a Lightning Tab from this component and used in Lightning Experience. Component: &lt;aura:component implements=&quot;force:appHostable&quot;&gt;     &lt;ltng:require scripts=&quot;/resource/treeTable/treeTableJS.js&quot; afterScriptsLoaded=&quot;{!c.loadScripts}&quot;/&gt;     &lt;aura:attribute name=&quot;temp&quot; type=&quot;String&quot; default=&quot;none&quot; /&gt;     &lt;aura:attribute name=&quot;content&quot; type=&quot;String[]&quot; default=&quot;item1,item2,item3,item4&quot; /&gt;     &lt;table id=&quot;table&quot;&gt;         &lt;tbody&gt;             &lt;tr data-tt-id=&quot;parent&quot;&gt;                 &lt;td&gt;&lt;ui:button label=&quot;Click&quot; press=&quot;{!c.selectClick}&quot; /&gt;&lt;/td&gt;                 &lt;td&gt;Content&lt;/td&gt;             &lt;/tr&gt;             &lt;aura:iteration items=&quot;{!v.content}&quot; var=&quot;item&quot; indexVar=&quot;index&quot;&gt;                 &lt;tr data-tt-id=&quot;{!'child'+index}&quot; data-tt-parent-id=&quot;parent&quot;&gt;                     &lt;td&gt;&lt;/td&gt;                     &lt;td&gt;{!item}&lt;/td&gt;                 &lt;/tr&gt;             &lt;/aura:iteration&gt;         &lt;/tbody&gt;     &lt;/table&gt; &lt;/aura:component&gt;  Controller: ({     loadScripts : function(component, event, helper) {         $(&quot;#table&quot;).treetable({                 expandable: true             }, {                 force: true             }, {                 initialState: &quot;collapsed&quot;             });     },      selectClick : function(component, event, helper) {         if(component.get(&quot;v.temp&quot;)===&quot;none&quot;){             component.set(&quot;v.temp&quot;,&quot;plus&quot;);             $(&quot;#table&quot;).treetable(&quot;expandNode&quot;, &quot;parent&quot;);         } else{             component.set(&quot;v.temp&quot;,&quot;none&quot;);             $(&quot;#table&quot;).treetable(&quot;collapseNode&quot;, &quot;parent&quot;);          }     }, })  Now about the issue, when I use this in Lightning tab first time it works (meaning straight forward scenario), but now from this page I navigate to any standard record page (be it Accounts record page) or even Home page and come back to this lightning tab, it does not work. We have to refresh the page to make it work again. Any resolve so that we don't need to refresh the page? Please help. Note: Lightning Locker service is disabled.
63292
I develop Joomla websites/components/modules and plugins and every so often I require the ability to use JavaScript that triggers an event when the page is loaded.  Most of the time this is done using the window.onload function.  My question is:    Is this the best way to trigger JavaScript events on the page loading or is there a better/newer way? If this is the only way to trigger an event on the page loading, what is the best way to make sure that multiple events can be run by different scripts?
50170
I need to view/generate PDF in Lightning component. How can I achieve that?  Do I have to user VF page with "renderAs" attribute inside Lightning Component? Or is there any other way to achieve this?
26816
I have a couple custom lightning pages and apps, both overriding default record views and standalone pages (just straight nav to from the sidebar). It seems that every time we go from 'tab' to 'tab' it just hides the content rather than destroying it. When you navigate back to the tab, it does recreate the components, so you end up with 2 of everything sitting out there.  I noticed this b/c we have a component that registers to an app event. And every time you navigate away from and back to the page, the handler is registered +1. So going back and forth a few times you pretty quickly have 10s of the same handlers firing for each app event.  Anyone seen this? Thoughts?  If you create a Lightning App, add this component, and assign it to lightning menu you can see what I mean. Just go the app click home and then click back:  Comp:  &lt;aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"&gt;     &lt;aura:handler event="c:BoringAppEvent" action="{!c.test}"/&gt;     hi     &lt;ui:button press="{!c.onClick}" &gt;App Event&lt;/ui:button&gt; &lt;/aura:component&gt;   controller:  ({     test : function(component, event, helper) {         console.log('Clicked');     },     onClick : function(cmp, evt){          var notEvt = $A.get('e.c:BoringAppEvent');          notEvt.fire();     } })   Renderer  ({     unrender: function(){         this.superUnrender();         console.log('unrender');         debugger;     } })   BoringAppEvent.evt  &lt;aura:event type="APPLICATION" description="Event template" /&gt;
56430
I'm not able to get refreshApex() working in an lwc. . Here are the key elements of the js file:  import { LightningElement, track, api, wire } from 'lwc'; import getBlasts from '@salesforce/apex/Blast.getBlasts'; import { refreshApex } from '@salesforce/apex';  export default class BlastWaveTree extends LightningElement {     @api recordId;     @track blastData;     @track error;     @wire(getBlasts, { CampaignId: '$recordId' })         wireBlastData({             error,             data         }) {             if (data) {                 let tempjson = JSON.parse(JSON.stringify(data).split('waves').join('_children'));                 this.blastData = tempjson;          } else {                 this.error = error;         }     }      @api     refresh() {         return refreshApex(this.blastData);      }   My code varies from the doc examples for 2 reasons:    The example code doesn't separate out the Apex response into error and data, the pattern I've been following as shown elsewhere. This data is going into a lightning-tree-grid so I have to process it a bit before assigning it to blastData.   I've tried return refreshApex(this.wireBlastData) as well, and that doesn't work.  Ultimately, I want to call the refresh function from the parent component (hence, the @api), but I've simplified it (till I get it working) by calling the refresh function from a button on this same component. I added a console.log line in the refresh() function so I know the button is calling the function. It just doesn't refresh. I'm also watching the apex logs as I push the refresh button, and there's no apex activity.  Here's the template:  &lt;template&gt; &lt;lightning-card title="Blasts" icon-name="custom:custom3"&gt;     &lt;div slot="actions"&gt;         &lt;lightning-button-group &gt;             &lt;lightning-button-icon icon-name="utility:refresh"  alternative-text="Refresh" onclick={refresh}&gt;&lt;/lightning-button-icon&gt;             &lt;lightning-button label={buttonLabel} onclick={toggleWaves}&gt;&lt;/lightning-button&gt;              &lt;lightning-button label="New Blast" onclick={onNewBlast} variant="Brand"&gt; &lt;/lightning-button&gt;         &lt;/lightning-button-group&gt;     &lt;/div&gt;     &lt;div class="slds-m-around_medium"&gt;         &lt;lightning-tree-grid              data={blastData}              columns={columns}              key-field="id"              hide-checkbox-column="true"              onrowaction={handleRowAction} &gt;         &lt;/lightning-tree-grid&gt;     &lt;/div&gt; &lt;/lightning-card&gt;     What am I missing?  Here's the error detail from the browser dev tools:      lds.js:2 Uncaught (in promise) Error: Refresh failed because resolved configuration is not available.     at Object.e.refresh [as refreshApex] (lds.js:2)     at l.refresh (blastWaveTree.js:4)     at callHook (aura_prod.js:24)     at sa (aura_prod.js:2)     at aura_prod.js:2     at _ (aura_prod.js:2)     at HTMLElement.e (aura_prod.js:2)     at l (aura_prod.js:2)     at Un.call.a (aura_prod.js:2)     at Array.forEach (&lt;anonymous&gt;) e.refresh   @   lds.js:2 refresh @   blastWaveTree.js:4 callHook    @   aura_prod.js:24 sa  @   aura_prod.js:2 (anonymous) @   aura_prod.js:2 _   @   aura_prod.js:2 e   @   aura_prod.js:2 l   @   aura_prod.js:2 Un.call.a   @   aura_prod.js:2 t   @   aura_prod.js:2 Lt  @   aura_prod.js:2 t.$$lwcEventWrapper$$   @   aura_prod.js:2
93178
I have created a Lightning web component named commonStyleSheets and deleted html, JS file and kept only CSS file as shown in the below image.  Now if I import it by using  'c/commonStyleSheets' in any other lighting component's CSS  I am keep getting below error  I have deployed the commonSyleSheets component on my sandbox but still keep getting the above error, does anyone have any idea to solve this issue in a sandbox?
123521
I have a VF page with lightningstylesheets = &quot;true&quot;. (This needs to stay this way-- when I take that away the whole page doesn't look right.) I need to save this VF page as a PDF to my Lead record, from an after update trigger. I am seeing that I cannot use renderas=&quot;pdf&quot; together with lightningstylesheets=&quot;true&quot;. I am also seeing that when I try to save the page as is as a pdf, it does not work-- the logs say  Internal Salesforce.com Error.  Does anyone have experience with a similar issue? How can I make this work? Here is the code I'm trying to get the body of the page as pdf:  PageReference pref = Page.SEEK_MVP_PDF_Display;         pref.getParameters().put('id',leadId);         Blob b; if(Test.isRunningTest()) {   b = blob.valueOf('Unit.Test'); } else {    b = pref.getContentaspdf();    system.debug('B: ' + b); } ContentVersion cv = new ContentVersion();         cv.versionData = b;         cv.title = 'SEEK Medicare Eligibility Check';         cv.PathOnClient = 'SEEK_Eligibility_Check.pdf';         insert cv;  ContentVersion Content = [SELECT id, ContentDocumentId FROM ContentVersion where Id = :cv.Id];         ContentDocumentLink contentlink=new ContentDocumentLink();         contentlink.LinkedEntityId= leadId;         contentlink.ShareType= 'V';         contentlink.ContentDocumentId= Content.ContentDocumentId;         insert contentlink;
13185
I have created lightning quick action to add my component for some functionality.   so from my quick action. When I do some validation like       var opp = component.get("v.objOpportunity");     if(!opp.Name.length || !opp.CloseDate.length )     {         var toastEvent = $A.get("e.force:showToast");         toastEvent.setParams({             "message": 'Opportunity name and close date can not be empty.',             "type": "Error"         });         toastEvent.fire();         return;     }   So the toast message display behind the modal. Please check below screenshot.   Any solution for this issue? I don't want to write custom error message functionality to display to user.
27088
I am building data table, here is html code from browser before rerendering table. I use actionFunction with rerender attribute. The problem is that svg disappears after rerendering.  Before rerender:  &lt;th aria-label="Account Name" class="slds-is-sortable slds-is-resizable" scope="col"&gt;     &lt;a class="slds-th__action slds-text-link--reset" href="javascript:void(0);"&gt;         &lt;span class="slds-assistive-text"&gt;Sort&lt;/span&gt;         &lt;span class="slds-truncate" title="Account Name"&gt;Account Name&lt;/span&gt;         &lt;div class="slds-icon__container"&gt;             &lt;svg aria-hidden="true" class="slds-icon slds-icon--x-small slds-icon-text-default slds-is-sortable__icon"&gt;                 &lt;use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/resource/1454076265000/SLDS01201/assets/icons/utility-sprite/svg/symbols.svg#arrowdown"&gt;&lt;/use&gt;             &lt;/svg&gt;         &lt;/div&gt;         &lt;span aria-atomic="true" aria-live="assertive" class="slds-assistive-text"&gt;&lt;/span&gt;     &lt;/a&gt; &lt;/th&gt;   After rerender:  &lt;th aria-label="Account Name" class="slds-is-sortable slds-is-resizable" scope="col"&gt;     &lt;a class="slds-th__action slds-text-link--reset" href="javascript:void(0);"&gt;         &lt;span class="slds-assistive-text"&gt;Sort&lt;/span&gt;         &lt;span class="slds-truncate" title="Account Name"&gt;Account Name&lt;/span&gt;     &lt;/a&gt;     &lt;div class="slds-icon__container"&gt;&lt;/div&gt;     &lt;span aria-atomic="true" aria-live="assertive" class="slds-assistive-text"&gt;&lt;/span&gt; &lt;/th&gt;   How to solve this? The response of request for rerender in Chrome dev tools looks like this:  &lt;html lang="en_US" xmlns="http://www.w3.org/1999/xhtml"&gt;   Maybe the issue is that xmlns="http://www.w3.org/2000/svg" is missing?
114745
I am trying to Preview and download document from LWC, From apex controller i am returning Map&lt;> contains ID and Document name, and iteration that map data in html file and passing map.key value to href url, but dynamic is not populating in URL.    &lt;template for:each={mapData} for:item="mapkey"&gt;                            Test: {mapkey.key}                                                         &lt;lightning-button-icon key={mapkey} icon-name="utility:download"  variant="bare" alternative-text="Settings"&gt;&lt;/lightning-button-icon&gt;                                &lt;a key={mapkey} style="color: #000000"  href ="/sfc/servlet.shepherd/document/download/{mapkey.Key}?operationContext=S1" target="_blank" preview= "{mapkey.value}"&gt;{mapkey.value}&lt;/a&gt;                          &lt;/template&gt;    JS Code:      .then(data =&gt; {            /// var conts = data;                   console.log('data map---&gt;'+data);     if(data){     // eslint-disable-next-line guard-for-in     for(let key in data) {    this.mapData.push({value: data[key], key:key}); //Here we are creating the array to show on UI.    }       } })   Apex Code:   @auraenabled /* Method will return a Map Contains Document ID and Name */ public static Map&lt;string,string&gt; getUrls( string searchstr){     Map&lt;string,string&gt; contdocidandtitle = new Map&lt;string,string&gt;();     system.debug('searchstr'+searchstr);             For(Document cd :[select id,folderid,name from document where folder.name =:searchstr]){         contdocidandtitle.put(cd.id,cd.name);                 }     return contdocidandtitle; }   Error is: sfc/servlet.shepherd/document/download/%7Bmapkey.Key%7D?operationContext=S1 in URL "mapkey.key" priniting instead of ID Help me with valuable suggestions.
9971
I'm trying to build a custom datable because I want the functionality to sort, search and paginate and also add action buttons in each row. Initially, my VF page was using  but we have now decided to rebuild that page in LWC.  I found a similar  but it hasn't really worked for me.  I then found  (Javascript) and  (ES2018) I have tried to implement Vanilla Datatables but I keep running into issues such as:      TypeError: Cannot read property 'length' of undefined   The above error is thrown because the library is unable to find the body of the table.   My point is that I feel this library won't work because it's using document, window and so on.   I was wondering if there is a way I could convert this library to something that is more suited to LWC basically have it "export" the modules. Since I'm not a JS expert I'm unable to put the pieces together.   Just for some context, I'll post my code here:  &lt;template&gt;     &lt;table class="sobject-table slds-table slds-table_cell-buffer slds-table_bordered"&gt;         &lt;thead&gt;             &lt;tr class="slds-line-height_reset"&gt;                 &lt;template for:each={fieldSetData} for:item="field"&gt;                     &lt;th key={field.apiName} title={field.fieldLabel} class="" data-scope="col"&gt;                         &lt;div class="slds-truncate" title={field.fieldLabel}&gt;{field.fieldLabel}&lt;/div&gt;                     &lt;/th&gt;                 &lt;/template&gt;             &lt;/tr&gt;         &lt;/thead&gt;         &lt;tbody&gt;             &lt;template for:each={records} for:item="row"&gt;                 &lt;tr key={row} class="slds-hint-parent"&gt;                     &lt;template for:each={row} for:item="data"&gt;                         &lt;td key={data.id} data-label="Name" data-scope="row"&gt;{data.value}&lt;/td&gt;                     &lt;/template&gt;                 &lt;/tr&gt;             &lt;/template&gt;         &lt;/tbody&gt;     &lt;/table&gt; &lt;/template&gt;   import {LightningElement, api, wire} from 'lwc'; import {processRecords} from 'c/recordGenerator'; import getFieldSetData from '@salesforce/apex/FieldSetData.getFieldSetData'; import getSobjectRecords from '@salesforce/apex/DeomoCTRL.getRecords'; import VanillaDatatable from '@salesforce/resourceUrl/VanillaDatatable'; import {loadScript, loadStyle} from 'lightning/platformResourceLoader';  export default class ManageSelectedIndicators extends LightningElement {     @api recordId;     records;     fieldSetData;     @wire(         getFieldSetData,         {objectName: 'SOBJECTName', fieldSet: 'FIELSETName'}     ) wiredFieldSetData({error, data}) {         console.log('wired called in Child')         if (data) {             this.fieldSetData = data;             this.getData();         }     }       constructor() {         super();         console.log('Constructor called in Child');     }      connectedCallback() {         console.log('Connected callback');     }      renderedCallback() {         console.log('Rendered callback');         Promise.all([              loadScript(this, VanillaDatatable + '/VanillaDataTables/src/vanilla-dataTables.js')          ]).then(() =&gt; {              const table = new DataTable(                  document.getElementsByClassName('.sobject-table'),                  //Also tried this.template.querySelector('.sobject-table'),                  {searchable: true, sortable : true}              );          })          .catch(error =&gt; {             console.log(error);          });     }      getData() {         getSobjectRecords ({             sobjectId: this.recordId         })         .then(response =&gt; {             this.records= processRecords(response, this.fieldSetData);         })         .catch((error) =&gt; {             console.log(error);         });     }  }   Edit: I have also tried lwc:dom="manual" that didn't seem to work either.  Is there any other way I could achieve these functionalities? Or do I have to write custom code to achieve this?
34251
I have a couple of applications built in Salesforce's Lightning Components.  Recently Salesforce released their Summer '16 Major Release this past weekend, on June 4th 2016. Something weird happened and now I'm getting a weird error every time I try to load any of my applications.   NOTE: I can load other JS libraries, such as svg4everybody just fine, jQuery is the only one I've tried that fails, and my applications heavily depend on it.  Error  Uncaught TypeError: Cannot read property 'expando' of undefined throws at /resource/jquery:5:8159   That's when I have the following code in a new Lightning Application that I created to see what is up with this jQuery load error. Here's the code I have in the new app:  &lt;aura:application&gt;   &lt;ltng:require scripts="{!$Resource.jquery}" afterScriptsLoaded="{!c.init}"/&gt;   &lt;div&gt;     &lt;button aura:id="buttonThingy" onclick="{!c.clickMe}"&gt;Click Me!&lt;/button&gt;   &lt;/div&gt; &lt;/aura:application&gt;   In the init function I've got this:  init: function(component, event, helper) {     console.log('running init'); },   Simple yes?  If I check Chrome's Console Log with the Log XMLHttpRequests checked in console settings, I can see that the request to load jQuery was a success since it says so...  app.js:713 XHR finished loading: GET "https://myOrgDomainName.lightning.force.com/resource/jquery".   Did anyone have this problem yet? If so how did you resolve it?  I've tried uploading minified, unminified, zipped up versions of jQuery to the Static Resources in my Org, and still no luck. Also switched between it being a Private and Public static resource. Still no luck.
106209
I have a webpage () that uses jQuery to load some SVG files from S3 through the CloudFront CDN.  In Chrome I will open an Incognito window as well as the console. Then I will load the page. As the page loads, I will typically get 6 to 8 messages in the console that look similar to this:  XMLHttpRequest cannot load  https://d79i1fxsrar4t.cloudfront.net/assets/img/feature-icons/documentation.08e71af6.svg. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://smartystreets.com' is therefore not allowed access.   If I do a standard reload of the page, even multiple time, I continue to get the same errors. If I do Command+Shift+R then most, and sometimes all, of the images will load without the XMLHttpRequest error.  Sometimes even after the images have loaded, I will refresh and one or more of the images will not load and return that XMLHttpRequest error again.  I have checked, changed, and re-checked the settings on S3 and Cloudfront. In S3 my CORS configuration looks like this:  &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"&gt; &lt;CORSRule&gt;     &lt;AllowedOrigin&gt;*&lt;/AllowedOrigin&gt;     &lt;AllowedOrigin&gt;http://*&lt;/AllowedOrigin&gt;     &lt;AllowedOrigin&gt;https://*&lt;/AllowedOrigin&gt;     &lt;AllowedMethod&gt;GET&lt;/AllowedMethod&gt;     &lt;MaxAgeSeconds&gt;3000&lt;/MaxAgeSeconds&gt;     &lt;AllowedHeader&gt;Authorization&lt;/AllowedHeader&gt; &lt;/CORSRule&gt; &lt;/CORSConfiguration&gt;   (Note: initially had only &lt;AllowedOrigin&gt;*&lt;/AllowedOrigin&gt;, same problem.)  In CloudFront the distribution behavior is set to allow the HTTP Methods: GET, HEAD, OPTIONS. Cached methods are the same. Forward Headers is set to "Whitelist" and that whitelist includes, "Access-Control-Request-Headers, Access-Control-Request-Method, Origin".  The fact that it works after a cache-less browser reload seems to indicate that all is well on the S3/CloudFront side, else why would the content be delivered. But then why would the content not be delivered on the initial page-view?  I am working in Google Chrome on macOS. Firefox has no problem getting the files every time. Opera NEVER gets the files. Safari will pick up the images after several refreshes.  Using curl I do not get any problems:  curl -I -H 'Origin: smartystreets.com' https://d79i1fxsrar4t.cloudfront.net/assets/img/phone-icon-outline.dc7e4079.svg  HTTP/1.1 200 OK Content-Type: image/svg+xml Content-Length: 508 Connection: keep-alive Date: Tue, 20 Jun 2017 17:35:57 GMT Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET Access-Control-Max-Age: 3000 Last-Modified: Thu, 15 Jun 2017 16:02:19 GMT ETag: "dc7e4079f937e83291f2174853adb564" Cache-Control: max-age=31536000 Expires: Wed, 01 Jan 2020 23:59:59 GMT Accept-Ranges: bytes Server: AmazonS3 Vary: Origin,Access-Control-Request-Headers,Access-Control-Request-Method Age: 4373 X-Cache: Hit from cloudfront Via: 1.1 09fc52f58485a5da8e63d1ea27596895.cloudfront.net (CloudFront) X-Amz-Cf-Id: wxn_m9meR6yPoyyvj1R7x83pBDPJy1nT7kdMv1aMwXVtHCunT9OC9g==   Some have suggested that I delete the CloudFront distribution and recreate it. Seems like a rather harsh and inconvenient fix.  What is causing this problem?  Update:  Adding response headers from an image that failed to load.  age:1709 cache-control:max-age=31536000 content-encoding:gzip content-type:image/svg+xml date:Tue, 20 Jun 2017 17:27:17 GMT expires:2020-01-01T23:59:59.999Z last-modified:Tue, 11 Apr 2017 18:17:41 GMT server:AmazonS3 status:200 vary:Accept-Encoding via:1.1 022c901b294fedd7074704d46fce9819.cloudfront.net (CloudFront) x-amz-cf-id:i0PfeopzJdwhPAKoHpbCTUj1JOMXv4TaBgo7wrQ3TW9Kq_4Bx0k_pQ== x-cache:Hit from cloudfront
97102
Is there any way to create and add lightning web components dynamically in the component tree ? I mean the equivalent one in Aura is $A.createComponent().  The usual Web Components can be dynamically created through standard DOM APIs like document.createElement('c-my-cmp') or element.appendChild(element), but as far as I tried in pre-release org it would not work at all.
22584
Okay, i'm looking to see if I can get some help in understanding the documentation as laid out here:   I want to refresh a component after a record CRUD operation, the form is being populated from a call to an apex method. The data from this method (called with the @wire service) is then passed into a js function that splits the data into complete and incomplete todo items. Wire service call is:     @wire(getTodos, {     searchKey: '$searchString'   })   sendForSplitting({     error,     data   }) {     if (error) {       this.error = error;     } else if (data) {       this.splitTodos(data);     }   }   In an event handler i want to trigger an update to this dataset, the documentation above seems to reference that I can refresh the apex on a wired method. From that doc:      To refresh a wired method, you must pass the argument the wired method receives (which is the wired value).   To date, I have tried both:     handleCreate() {     return refreshApex(getTodos, {       searchKey: '$searchString'     });   }   and    handleCreate() {     return refreshApex(this.sendForSplitting({       error,       data     }));   }   Both of which throw errors - refresh failed because configuration is not available. How can I make this work? I want to ensure the lists update upon user interaction without having to resort to a manual refresh of the page...
99580
I am new to Salesforce development. I made a trigger that creates a new asset record and autofills some of the fields on said record. What I want ultimately would be a button that I can put on the "Products" related list on the opportunity page that does what my trigger does. From what I understand, I can't just call my trigger on the button click, and I have to create a VF page or an Apex class that uses the trigger's logic. Does anyone know how I would go about doing this? Here's my code:  trigger ConvertOpportunitiesToAssets on Opportunity (after update) {      List&lt;Asset&gt; a = new List&lt;Asset&gt;();     OpportunityLineItem oli = new OpportunityLineItem();      for(Opportunity o: Trigger.new)     {                   a.add( new Asset(             PSI_Supplier__c = o.Supplier__c,             PSI_Opportunity__c = oli.Product2Id,             AccountId = o.Accountid,             Name = oli.Product2Id,             Product2Id = oli.Product2Id,             Product_Name__c = oli.Product_Name__c             ));            }     insert a; }   Thanks in advance!  UPDATE So I tried making the trigger into a class and button (thanks sfdcfox!), but now it won't work. Here's what I've got:      global class OpportunityWS{     webservice static void createAsset(Id opportunityId)     {         List&lt;Asset&gt; a = new List&lt;Asset&gt;();         Opportunity o = new Opportunity();         OpportunityLineItem oli = new OpportunityLineItem();          a.add( new Asset(             PSI_Supplier__c = o.Supplier__c,             PSI_Opportunity__c = oli.Product2Id,             AccountId = o.Accountid,             Name = oli.Product2Id,             Product2Id = oli.Product2Id,             Product_Name__c = oli.Product_Name__c             ));                 insert a;      } }  {!RequireScript("/soap/ajax/34.0/connection.js")} {!RequireScript("/soap/ajax/34.0/apex.js")} function success() { var alertString="Success!";  alert(alertString);  } function error() { var alertString="Error!";  alert(alertString);  } sforce.connection.sessionId = "{!$Api.Session_ID}"; sforce.apex.execute("OpportunityWS", "createAsset", { opportunityId: "{!Opportunity.Id}" }, { onSuccess: success, onFailure: error });   I can't tell if it's something wrong with the class or the button. I think it must be the class.  UPDATE(AGAIN) Alright so I followed Doug's advice and tried to use the opportunityId to query the opportunity and opportunityLineItem sobjects, was able to compile without errors. But now I'm getting the error message that I made in the button thrown and the asset isn't being created. Unfortunately, I haven't been able to track down the issue. Here's the OpportunityWS apex class that I've updated since last edit:  global class OpportunityWS{ webservice static void createAsset(Id opportunityId) {     List&lt;Asset&gt; a = new List&lt;Asset&gt;();     List&lt;Opportunity&gt; o = [SELECT Supplier__c, Accountid FROM Opportunity WHERE Id = :opportunityId];     List&lt;OpportunityLineItem&gt; oli = [SELECT Product2Id, Product_Name__c FROM OpportunityLineItem WHERE Id = :opportunityId];      a.add( new Asset(         PSI_Supplier__c = o[0].Supplier__c,         PSI_Opportunity__c = oli[0].Product2Id,         AccountId = o[1].Accountid,         Name = oli[0].Product2Id,         Product2Id = oli[0].Product2Id,         Product_Name__c = oli[1].Product_Name__c         ));             insert a; }   }
90064
I have a lightning web component that it's data needs to be updated whenever the record is saved.  Is it possible to trigger a function\component refresh when the record is save?