This article covers how to refresh data in a lightning web component with refreshApex. If you are looking for a how-to on refreshing the entire page or tab from a lightning web component, check out this post. In this simple example, the component contains a refresh button and information about a contact. We get the contact information in a wire function. If the contact updates, the cached data becomes stale. Import the refreshApex method and…
Help text in Salesforce is obviously readily available in the UI, but not so much when putting together reports. You may also want to see an overview across different objects for evaluating a system clean up & ensuring help text exists and is up to date. Here’s how you can export it by running a simple APEX script. Using Schema.SObjectField Let’s start with fields on a single object (further down we discuss exporting help text…
Scenario The accounting department wants to send automatic reminders for due & overdue invoices. They want to send these on the due date, as well as one & three business days after the due date. In this example, every invoice record has a due date field (Due_Date__c) and a status picklist field (Status__c) with the values Draft, Invoiced & Paid. Solution You set up a process builder flow that fires when the invoice status switches…
I generally use custom settings & labels to avoid hardcoding values, strings, etc. in APEX. Here’s how you can pass them to a Lightning web component. Let’s assume I want to use a custom setting called My_Custom_Setting__c with 2 fields (Field1__c, Field2__c) and 3 custom labels (labelName1, labelName2, labelName3). This is what the APEX class could look like: Custom settings are pretty straight forward: return the setting you need in an aura enabled method. For…
Writing to .csv from APEX is super helpful for creating a report-like output from a query. Especially for once-off complex reporting requests where regular report filtering is not cutting it and you want to apply additional logic. Consider this scenario: You uploaded several thousand contacts but something went wrong and a bunch of duplicates were created. For arguments sake, you don’t run any regular deduping on that object. You could create a report of all…
The problem Response handling is an important part of building automations for a help desk. Email responses can be handled declaratively, but chatter comments are a bit trickier. Here’s an example for email-based support that I’ll show you how to replicate for chatter responses: A help desk rep responds to a case via email with further questions. They set the case status to “Waiting on Response” (or any custom pending picklist value). When this pending…
As a generally optimistic developer, error handling tends to be a bit of an afterthought for me. Luckily, the modularity of lightning web components can be put to good use here. With a dedicated error handler that can be embedded in other components, I only need to worry about building error handling once. LEX has some default error handling, but it’s a bit clunky & more helpful to developers than end users. Do you think…
This article covers how to refresh the entire page or tab from a lightning web component. If you are looking for a how-to on refreshing data inside a lightning web component, check out this post. A Lightning web component can refresh itself & data in child components, but it cannot directly refresh the record page tab it lives on. Aura components, however, can refresh tabs just fine. Yes, this is annoying and inconvenient for many…