Posts

Showing posts with the label JavaScript

Custom File Upload to Salesforce using LWC and Apex

Hi Everyone, In this blog, we'll explore custom way of uploading a file to salesforce using Apex and lightning-input tag.  A file can be uploaded using either lightning-file-upload component or lightning-input (having type attribute as "file") component. Only difference between lightning-file-upload and lightning-input with type as 'file' is that files uploaded by using file-upload component directly get attached to records without writing any additional apex code, whereas you need to write Apex code for attaching files to record while using lightning-input component. Some important points Multiple files can be uploaded by having multiple attribute in component definition. All types of files are accepted and furthermore you can restrict what kind of file you want to upload by specifying valid file formats in accept attribute. Ex:- [".pdf", ".doc", ".jpg"] Uploaded files can be associated to a record by specifying record-id attri...

Client Side Pagination in LWC Component

Image
 Hi Folks, Hope you all are well !! In this post, we are gonna implement a simple client side pagination. Making use of client side pagination is much more simple then having all logic into Apex Class and doing SOQL on each click of Pre and Next button. Let's simplify pagination in below steps :- Get all the result in single Apex call. Hold the main result to a object type variable which further will be used to process the logic on each pre/next button click. Decide how many records needed to show on the page. Process the logic for displaying default number of records and when click on pre and next button. Handle the logic when records on page got changed. for the pagination logic, we have created a separate (child component) which will takes some property from its parent component and will process it accordingly. (Reusability feature). paginationlwc.cmp <template>     <lightning-card title = {cardTitle} >         <div style = "height:...

Using Lightning Message Service aka LMS in LWC

Hey, Welcome Folks !! Let's talk about LMS.  Before going to LMS, lets understand little bit about Lightning Message Channel. Lightning Message Channel is a metadata that stores communication parameters or message. Use this message channel to publish/subscribe the message. Lightning Message Service is unique salesforce feature that allows developers to communicate across the DOM within a Lightning Page (i.e. unrelated components) , using a secure message channel. See the LMS as Application Events in aura framework that allows communication between the components on an application. Using LMS, we can communicate between Visualforce Pages embedded into lightning page, Aura Components, Lightning Web Components, Utility bar components. There are three main steps to use LMS into you web components: Creating a Lightning Message Channel. Publishing the message to Message Channel. Subscribe/Unsubscribe from Message Channel. Creating a Lightning Message Channel Create a folder under force:ap...

How to use Javascript in visualforce page

Here I am taking a basic example of using Javascript in a visualforce page that illustrates how to call javascript function from VF page and how to reference id of a visualforce component. Use $component global variable to referencing DOM Id that is generated for a visualforce component. <apex:page>   <script>       function show(tid,sec){                     document.getElementById(sec).value = document.getElementById(tid).value;              }             </script>   <apex:form >       <apex:pageBlock >           <apex:pageBlockSection id="lab" >               <apex:inputText id="name" label="AccountName"/>               <apex:inputText id="second" label="Rating"/> ...