A blog about Salesforce CRM Configuration and development

Saturday, 5 October 2019

LWC Local Development Beta | Local Development Setup# and Installation


LWC ( Lightning Web Component) Local Development Beta is released by Salesforce.  This local development feature will help us to build, run and test the lightning web component on our local machine, we do not need to deploy the code on our salesforce org. Big Thanks to the LWC team.
This (Local Development) will reduce the time for LWC development and testing. This will definitely increase the productivity of the salesforce developer.


The Local Development Server is available through the Salesforce CLI plugin. It is configured and runs a Lightning Web Component enabled server on the local machine.

Setup# and Installation: 


Setup: 

Installation:
  • Open a terminal window (CMD run as administrator) run the following command to install the LWC local development server on your machine.
 sfdx plugins:install @salesforce/lwc-dev-server

  • Check for updates to the local development server.
 sfdx plugins:update





  • Open your VS Code IDE and add the.localdevserverfolder in your SFDX project to your.gitignorefile. Do not modify files inside of this folder.


  • Authorize a Developer Hub (Dev Hub) in the VS Code and through CMD.
sfdx force:auth:web:login --setdefaultdevhubusername
  • Log in using your Dev Hub credentials.



  • Start the server.
sfdx force:lightning:lwc:start

  • You can see all the LWC that you created in your org. Click on your favorite component to run.


  • c-hello-web-component: you can see this web component rendered in-browser without deploying to the org.
  • If you click on the button “View in VS Code” this will quickly open the component code in your VS Code IDE. When you can make any changes in the component code, those changes will refresh in the browser immediately.


Thanks
Arun Kumar



Share:

Tuesday, 10 September 2019

ChartJS Lightning Component | Draw Beautiful Report Chart Using Chart JS


In this blog post, I am going to share a lighting component which will display a chart based on the selected report and chart type. In this component, I have used the Chart.JS open-source javascript library to draw chart in lightning component. The user can select the report and chart type to draw/display the chart and the selection of report name and chart type will be remembered for the user.


Chart JS is a javascript library that allows us to design and draw the different kinds of charts using the HTML 5 canvas element. We can use this library to draw a simple, clean and animated chart. Below are some advantage of using this library for drawing chart.
  • It is open source.
  • We can use 8 chart type to display the chart.
  • HTML5 canvas (great rendring performance across all the modern browser)
  • It is responsive.

I have created a package which you can install in your salesforce instance.

RPTChart: Download/Install


Find the full code here.

References:



Share:

Saturday, 8 June 2019

Task Transfer Tool | Lightning Component | Mass Task Transfer

Task Transfer Tool.
Select multiple tasks to be transferred.
Select a user to which tasks will be assigned.
Task Re-Assigned successfully!
Search Tasks...

Task Transfer Tool - This is a tool which will transfer multiple task record from one user to another.

Sometimes we need to reassign large quantities of tasks, for example, when a staff/employee member is out and someone else will be working their tasks for that day. Editing the tasks one by one is not feasible and it is time-consuming. If we can transfer them in a single transfer it will save hours of time.


I have developed the lightning component which will do the mass task transfer:

Tool Features:
  • Mass task transfer ( Task re-assignment in a single click)
  • Search tasks which need to be transferred.
  • Easy to use, it can be used on the Home page, Lightning component tabs, etc.
  • It can be used on the Salesforce 1 mobile app.
OR




Share:

Sunday, 26 May 2019

OWD "Public Read Only" | Only record owner can edit their own records?

Scenario: There is a custom object, it's record should be visible to everyone (users) but only record owner can edit the record. When someone edits a picklist field, the record should be automatically assigned to the groups of the user to work on and they can edit the record and the previously assigned user should not edit the record.


Solution: Below is the steps to set up the things for the above requirement.
  • OWD: for this custom object will be "Public Read Only". (All user can see the record who has object access permission) 

  • OWD ( Organization Wide Sharing Default): It defines the default access level for an object’s records. The organization-wide sharing settings can be set to Private, Public Read Only, or Public Read/Write. 
  • Profile: The users who are going to see and work on the record should have 'Read','Edit' permission on the object.
  • Create queues for different users. (Setup -> Queue-> New)

  • Queue1 : Assigned User( User 1, User 2 )
    Queque 2: Assigned User ( User 3, User 4 )

  • Create a Process Builder: Assigned the record to the queue based on the selected picklist.
Setup -> Process Builder -> New
















Result: When the user changes the 'Level' picklist field value automatically record will be assigned to 'Queue' ( multiple users) with the help of Process Builder.

The record will be read-only to the users and only owner and the user who created the record will be able to edit the record.

Thanks.

Arun Kumar

Share:

Monday, 6 May 2019

Retrieve CustomField Metadata Information Using Tooling API

Sometimes Salesforce admin/user needs to know which custom fields created in a certain time frame like THIS Week/Month/Year, etc.

We can use Salesforce Tooling API to get the CustomField information. We can query the CustomField metadata information inside Salesforce developer console, you just need to check the "Use Tooling API" checkbox. Below is the screenshot showing the lists of custom fields created this year. 

Query: SELECT DeveloperName,CreatedDate,TableEnumOrId FROM CustomField where CreatedDate = THIS_YEAR



Q. How to export the data showing in dev console in CSV format?

Ans~ We can use the 'SDFC Dev Console Data Exporter' google chrome extension for that.

SFDC Dev Console Data Exporter (Screenshot)

Q. What is the Tooling API?

Ans~ Tooling API exposes metadata information of Org, we can access Metadata information using REST or SOAP. Tooling API retrieve the small piece of metadata, we can use this to develop an interactive application or tools for developers.

We can accomplish the following tasks using the Tooling API:
  • Retrieve metadata about an object’s field.
  • Retrieve metadata of custom and standard object properties.
  • Get metadata information about Apex Classes, Visualforce Pages, Apex Triggers.
  • Get Code coverage details of Apex classes and Trigger.
  • Retrieve metadata information about ValidationRule and WorkflowRules.
  • Query RecentItems used in your SFDC org.
  • Etc...
Share:

Sunday, 5 May 2019

Mailchimp Batch Operation | Salesforce - Mailchimp Integration | Mailchimp REST API










MailChimp Batch Operation: We can use this batch operation in the MailChimp API to complete more than one operation in just a single call. Let's take an example where you need to subscribe and unsubscribe the records. In the simple API call, you have to do separate call to make the single record to subscribe and unsubscribe in the MailChimp list this may exceed your API call out limit. The batch operation runs in the background on the MailChimp server and does the more than one action in just a single API call. After callout, we can check the batch status.



Scenario: There is a field on Contact records 'Email Opt Out', whenever user update the field to uncheck subscribe the record in the MailChimp list and vice versa.

MCSubscribeUnsubscribeTrg
MCSubscribeUnsubscribeHelper


Find the code on Github here

Happy Coding...

Reference:
https://developer.mailchimp.com/documentation/mailchimp/reference/batches/
https://developer.mailchimp.com/
Share:

Saturday, 4 May 2019

Edit Action On Account [Contacts] Related List In Lightning Experience



On the Account page, we have the 'Edit' action on the related Contact list in Salesforce classic user interface as shown in the screenshot below.


But if you see the same in the Lightning experience user interface, the user first needs to click on the 'down' button icon then they can see the 'Edit' action option and from there they can click on 'Edit' action.


In the Lightning user interface, the user needs to do an extra click to do the same as they were doing in a single click in Salesforce classic user interface.

I have solved the issue with a workaround (a field and URL hack) in one of my projects.

Create a formula field on Contact object with return type as Text.

Formula:

HYPERLINK(
"https://[custom domain].my.salesforce.com/" & Id & "/e?retURL=https://[custom domain].lightning.force.com/lightning/r/"
& AccountId & "/related/AccountContactRelations/view?0.source=alohaHeader" ,"Edit")


Add the created field in the Account (Contact Related list) page layout.


Result:




Share:

Wednesday, 1 May 2019

Copy To Clipboard | Lightning Component | Copy sObject Record Link


Hello Guys,

In this blog post, I am going to share the 'Copy To Clipboard' functionality in the lightning component using javascript. While working with the records in Salesforce sometimes user needs the record link to share in an email or need to use in the documentation or somewhere else.


This component will copy the record link in the clipboard in just a single click, the user does not need to copy the record link from browser URL. The component can be used for every standard and custom object, the user just needs to add the component on the object detail page and needs to click on the link button icon, the record link will be copied in the clipboard.

Find the full component code below.

copyToClipboardCmp
copyToClipboardCmpController copyToClipboardCmpHelper copyToClipboardCntrl

Full code on GITHUB.
Happy Coding...! 
Share:

Saturday, 23 March 2019

Material Designed DataTable In Visualforce Page.

Q. What is material design?

Ans:- Material design is a design technique/language. It uses a grid-based layout, responsive animation, and transition, padding, depth effects show as lightning and shadow. It is designed to optimize user experience with natural motions, 3D effects, and realistic lighting.

DataTable: It is a plug-in for the jQuery Javascript library. It will add features like fast search in the table, paginations, column sorting, etc with the minimum code.



In this example code, I have used DataTable (Jquery plug-in javascript library) in the visualforce page. Find the full code below.

 <apex:page controller="DatatableCntrl" sidebar="false">  
 <head>  
   <apex:includescript value="https://code.jquery.com/jquery-3.3.1.js"/>  
   <apex:includescript value="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"/>  
   <apex:includescript value="https://cdn.datatables.net/1.10.19/js/dataTables.material.min.js"/>  
   <apex:stylesheet value="https://cdnjs.cloudflare.com/ajax/libs/material-design-lite/1.1.0/material.min.css"/>  
   <apex:stylesheet value="https://cdn.datatables.net/1.10.19/css/dataTables.material.min.css"/>  
   <script>  
   j$ = jQuery.noConflict();  
   j$(document).ready( function () {  
     var accTable = j$('[id$="accTable"]').DataTable({  //datatable 
        columnDefs: [  
     {  
       targets: [ 0, 1, 2 ],  
       className: 'mdl-data-table__cell--non-numeric'  
     }  
   ]  
     });  
   });  
   </script>  
   <style>  
     div.dataTables_wrapper div.dataTables_filter {  
     text-align: right;  
     margin-right: 2%;  
     /* border-radius: 2px; */  
     /* height: 51px; */  
   }  
   </style>  
 </head>  
 <body>  
   <table id="accTable" class="mdl-data-table" style="width:100%">  
     <thead>  
       <tr>  
         <th>Name</th>  
         <th>Billing State</th>  
         <th>Website</th>  
       </tr>  
     </thead>  
     <tbody>  
       <apex:repeat value="{!accList}" var="acc">  
         <tr>  
           <td>{!acc.Name}</td>  
           <td>{!acc.BillingState}</td>  
           <td>{!acc.Website }</td>  
         </tr>  
       </apex:repeat>  
     </tbody>  
   </table>  
 </body>  
 </apex:page>  

 public class DatatableCntrl{  
   public List<Account> accList {get; set;}  
   public DatatableCntrl(){  
     accList = [SELECT Name, BillingState,Website FROM Account where BillingState!='' and Website !='' order by name ];  
   }  
 }  


References:

Share:

Make only one record active at a time of same record type.


Scenario: Make only one contact record active at a time of the same record type on Account.

Solution: Using Apex Trigger: Create a trigger on the contact object for insert and update event. Find the code below.

 /* Name: deactivateContact  
  * Description: Make only one record active at a time of same record type.  
  * Created By: 23/03/2019  
  * Last ModifiedDate: 23/03/2019  
  * Created By: Arun Kumar  
 */  
 trigger deactivateContact on Contact (before update, before insert) {  
   if(Trigger.isBefore){  
     if(Trigger.isUpdate || Trigger.isInsert){  
        if(deactivateContactHelper.isFirstTime){ // check for recursive call  
         deactivateContactHelper.isFirstTime = false;  
         deactivateContactHelper.updateContact(Trigger.new);   
        }  
     }  
   }  
 }  

 /* Name:deactivateContactHelper  
  * Description: Update isActive field on contact( Only one contact record will be active at a time of same record type).  
  * Created Date: 23/03/2019  
  * Last ModifiedDate: 23/03/2019  
  * Created By: Arun Kumar  
 */  
 public class deactivateContactHelper {  
   public static boolean isFirstTime= true; // for recursive call check  
   // update isActive field ( Only one contact record will be active at a time of same record type).  
   public static void updateContact(List<Contact> contactList){   
     set<id> parentId = new set<id>();  
     set<id> recordId = new set<id>();  
     set<id> recordTypeIdSet = new set<Id>();  
     for(Contact c: contactList){  
       if(c.isActive__c){  
         parentId.add(c.AccountId); // accountid  
         recordId.add(c.id); // record id  
         recordTypeIdSet.add(c.recordTypeId); // recordtype id  
       }  
     }  
     List<contact> ContactForUpdate = new List<contact>(); // contact list for update  
     for(Contact con:[select id,isActive__c from contact where accountid IN: parentId and Id NOT IN: recordId and recordTypeId IN:recordTypeIdSet]){  
       con.isActive__c = false;// isActive__c = FALSE  
       ContactForUpdate.add(con);   
     }  
     if(ContactForUpdate.size()>0){  
       try{  
         update ContactForUpdate;// Update rest contact list  
       }  
       catch(Exception e){  
         system.debug('Exception has occred! ' +e.getMessage());  
       }  
     }   
   }  
 }  
Share:
Trailhead Profile


Follow by Email

Total Pageviews

Followers

Popular Posts

Powered by Blogger.

Contact Form

Name

Email *

Message *