Connecting Sandbox (Dev) to Visual Studio code For Developing Lightning Web Components(LWC)

Here, I am going to present you the steps to connect the Sandbox to Visual Studio Code for connecting the Lightning web Component…

First step: Install Salesforce Extensions for Visual Studio Code

screenshot for Extensions in VS Code
Lightning Web Components Extension

Login in to Sandbox and Use the below command in the Terminal

sfdx force:auth:web:login –setalias my-hub-org –instanceurl https://test.salesforce.com

After logging in…

  1. Use ctrl+shift+p
  2. Enter Sfdx:create Project
  3. Select the Source where you want to create Project.

To Create Lightning web Component use the Below Command in Terminal

sfdx force:lightning:component:create –type lwc -n myComponent -d force-app/main/default/lwc

AND Finally to deploy use the command below:

sfdx force:source:deploy -p force-app -u  test@example.com(user name of the Sandbox)

Also, Follow the Link below for better experience on Lightning Web Component:

https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components

-Ranjith T [02/25/2019]

Cron expression for scheduling jobs in Salesforce

In this post, I am going to share the information about Cron expression for scheduling jobs in Salesforce

Use schedule with an Apex class that implements the Schedulable interface to schedule the class to run at the time specified by a Cron expression.

System.Schedule(JobName, CronExpression, SchedulableClass)

Sample Code

ExampleSchedulableClass testobj = new ExampleSchedulableClass();

String cronexpression = ‘0 0 0 ? * * *’

System.schedule(‘Testing’, cronexpression, testobj);

The Above Code Executes ExampleSchedulableClass At 12:00 AM Every Day .

Cron Expression

Cron Expression syntax :-
“Seconds Minutes Hours Day_of_month Month Day_of_week optional_year”

The following are the values for the expression:

Name Value
Seconds 0–59
Minutes 0-59
Hours 0-23
Day_of_month 1-31
Month 1-12
Day_of_week 1-7
optional_year null or 1970–2099

Cron Expression Examples

Expression Description
0 0 0 ? * * * at 12:00 AM every day
0 0 10 ? * * at 10.00 AM every day
0 0 10 * * ? at 10.00 AM every day
0 0 10 * * ? * at 10.00 AM every day
0 0 15 ? * * * at 3:00 PM every day
0 0-5 15 * * ? Every minute starting at 3:00 PM and ending at 3:05 PM, every day
0 15 17 ? * MON-FRI at 5:15 PM every Monday, Tuesday, Wednesday, Thursday and Friday
0 15 10 15 * ? at 5:15 PM on the 15th day of every month
0 15 17 ? * 6#3 at 5:15 PM on the third Friday of every month
0 0 18 ? * 6L runs the last Friday of every month at 6:00 PM.
‘0 30 * * * *’; every 30 minutes
0 0 12 * * ? at 12:00 PM every day
0 0 23 * * ? 2016 runs every day at 11:00 PM during the year 2016.
? – No Value
* – All Values
L – Last
– Chandra V [01/12/2019]

Validation Rule Requiring Lead Fields Prior to Conversion

In this post I am writing a validation rule that requires all of these fields prior to Lead conversion.

Need is a checkbox, Languages and propsepct role are picklists, Notes and SDR are text…

Below is the successful Formula that works for the above criteria:

Also, If the  Notes__c a Rich Text area field, then you need to use this:

 

If the above don’t work either, then check the following:
This Lead Settings should be checked in order for the Validation Rule to Fire.
Hope this information helps you!
– Chandra V [01/12/2019]

 

Spring ’19 Salesforce Lightning Experience Highlights

 

Here!! In this Post, I tried to Point out the Most prominent Highlights of the Salesforce Spring’19 Release…

 

  1. Salesforce solicits feedback randomly to a subset of users in an org. Starting March 2019, a feedback form now appears in Lightning Experience to hear from more users, appearing at the bottom of the app. Admins can disable the form.
  2. Lightning Web Components are Generally Available. Lightning web components are custom HTML elements built using HTML and modern JavaScript. They can co-exist with Aura Components (formerly known as Lightning Components). For more information about LWC, access the release notes.
  3.  Remove the account team and opportunity team in one click instead of one at a time.
  4.  Now, when you transfer account ownership, you have additional options of what you want done just to open opportunities and open cases, or to all opportunities or cases.
  5.  You can now pin a list as your default list view instead of having it default to the Recently Viewed. Just navigate to the list view and pin it.
  6.  You can now print pages in Lightning for account, campaign, case, contact, contract, lead, opportunity, order and custom objects! From a Lightning record page, click on the Printable View button. It will show the details expanded and collapsed depending on the visibility of the record page.
  7.  (Critical Update) In lightning console apps, there is now the ability to pop-out most standard utilities into its own window. Review the release notes for the standard utilities.
  8.  Subtabs in the console app gets some love. If a rep needs more space than a subtab, a rep can set a subtab as a workspace tab, refresh tab, etc.
  9. You can now specify a two region page template for console apps.
  10.  Add Lightning Web Components to your utility bar by adding lightning_UtilityBar target to the lighting Web component’s meta configuration.
  11.  (Critical Update) Lightning Experience Honors Target Values for Hyperlinks in formula fields. This CU is enabled in Summer ’19 on 5/17. Prior to the CU, Lightning ignore the target value when opening a hyperlink.
  12.  Email Enhancements:
    You can now store email templates into nested folders beyond the Private and Public folders
    Set access to email templates based on the folder it is stored in.
  13.  Your reps can quickly complete tasks in a button click. Your reps can also re-open a completed task.
  14.  Calendar enhancements:
    The ability to schedule recurring event series is generally available. Users can view, schedule and update events in a public calendar without switching to Salesforce Classic.
    Assign resources to events. In Setup, create a resource calendar. Then add Attendees to the Event page layout.
    Reps can add Salesforce users, contacts, person accounts, and leads to their events without using Lightning Sync. Just add the Attendees field to the Event page layout.
    Users of Chrome, Internet Explorer and Firefox can print up to 12 hours of events in a week view or an entire month from the calendar view.
    If file(s) is/are associated to an event, anyone with access to the event can view the files.
  15.  Survey enhancements:
    Translate your surveys in more than 10 languages
    Use two new questions. The Net Promoter Score® (NPS®) question type helps you assess your customers’ loyalty for your products and services. The Ranking question type helps you gauge your participants’ preferences from a list of choices.
  16.  Forecasting enhancements:
    Sales teams can forecast product family revenue by sales territory. This includes teams who use Collaborative Forecasts.
    Forecast managers can share their territory forecasts with any Salesforce user. This includes teams who use Collaborative Forecasts.
    Add sales reps to groups and queues based on territory assignment.
  17.  Lightning Knowledge Migration Tool (Generally Available) – Now, you can use a tool to migrate your Salesforce Knowledge to Lightning Knowledge. You will need to contact Salesforce Support to enable this and test out the migration in a full copy sandbox prior to enabling the migration in Production.
  18.  Lightning Knowledge enhancements:
    In Lightning, you can now manage Knowledge articles with Add the Restore, Edit as Draft, and Archive buttons.
    Use the Insert Article to Email Action to attach Knowledge article files from the related list.
  19.  Community users can now request contact, which allows them to provide information on the issue and request an agent to call them back to provide support.
  20.  Agents have the ability to pop-out their softphone utility into its own window.
  21.  Use relative dates in macros. Select Relative for date and time fields and specify the value and duration.
  22.  Ability to select Add Close Tab Instruction in a macro to close the tab after the macro is completed.
  23. You now have the ability to have agents send email drafts to approvers when they’re communicating with customers.
  24.  Ability to view a case hierarchy when working cases.
  25.  Ability to view case contact roles.
  26.  You can now get a quick view of up to 8 key metrics in a report in the Lightning Experience report header. Additionally, column headers are now sticky.
  27.  Resize report column widths in Lightning Experience report builder and the run page.
  28.  Ability to switch between 12- to 9-column for Dashboard width sizes.
  29.  You can now create one row by one column (1×1) components on your dashboard.
  30.  Ability to set up group or role subscriptions to reports or dashboards so your lists remain current when users are added or removed from a group or role.
  31.  You can now add hyperlinks in a Chatter post and comment.
  32.  Organize your asset library files into folders.
  33.  Create a Flow to Let Community Users Request Help: Using a flow solution, let community users request your support reps call them back. Use the new Contact Request Flow type and the Create Customer Contact Request action when creating your flow.
  34.  Switch Your Lightning Page to a Different Template. This is huge. Have you ever created a lightning record page only to find out that it is better with a different template design and you had to re-create the page from scratch in the new template? Now, you can change the template and specify where the existing components should move to.
  35.  (Beta) Get Things Right with Right-to-Left Languages: For Arabic, Hebrew, and Urdu customers, columns and sidebars flow from right to left, and text is aligned appropriately.
  36.  Create Objects from Spreadsheets: Create a custom object by importing its fields and field data from a Google sheet, a Quip spreadsheet, an Excel file (.xls or .csv format). This can be done from the Navigation Items tab inside a Lightning app in Lightning App Builder. Edit a Lightning app, access the Navigation Items tab, then click the “Create” button at the top of the Available Items list.
  37.  Assign Default Home Pages Based on the Lightning App
  38.  When you platform encrypt the Event Description field, your event series also becomes encrypted.
  39.  Visualforce Enhancements: Show a Toast with a New JavaScript Function using the sforce.one.showToast() function.
  40.  Lightning Components: Navigate to a URL with the standard__webPage Page Reference Type: The standard__webPage type replaces the force:navigateToURL event. Refer to pageReference Types in the Spring ’19 Lightning Components Developer Guide for more information.
  41.  Reference Asset Files with the $ContentAsset Global Value Provider: Rather than reference files using long file paths or URLs, you can now reference a specific asset file in component using $ContentAsset.assetDeveloperName or for orgs with a namespace, $ContentAsset.yourNamespace__assetName.

Sumanth A [01/08/19]

EINSTEIN ANALYTICS – 50 Ways Salesforce Einstein Analytics Can Improve Your Business

In this Post, I would like to get the most important points on the Einstein Analytics to this Blog, through which one can understand it’s significance in improving the Business.

  1. Work with a platform you can trust: Enjoy the peace of mind that comes from working with the most celebrated customer-relationship platform available on the market.
  2. Save on expenses: Decrease operating costs by using an analytics platform that operates entirely out of the cloud. This means no expensive installation or maintenance costs, and no need to invest in analytics-specific onsite hardware.
  3. Get set up quickly: Take advantage of advanced analytics within minutes, thanks to powerful big-data solutions available right out of the box.
  4. Cut out the fluff: Don’t waste money paying for features you don’t use. Salesforce Einstein Analytics offers multiple packages and per-use pricing, so you always have the analytics tools you need, at a price that you can afford.
  5. Customize your solution: Trust the analytics tool that conforms to the unique needs of your business. Salesforce Einstein Analytics is built on a fully customizable CRM platform, designed to meet you more than halfway. With Einstein Analytics, you’ll always have the analytics solution that works best for you.
  6. Enjoy built-in support: Take the confusion out of data analysis. Salesforce Einstein Analytics offers built-in guides, tutorials, and multi-channel support options, so you’ll never have to worry about not getting the most out of your analytics solution.
  7. Integrate your data: Don’t wait for your IT teams to optimize your software for data analysis. Salesforce Einstein Analytics incorporates analysis tools into every application and system, meaning integrated, easy-to-use analysis functionality that leads to faster results.Salesforce knows that when it comes to on-point data analysis, the last thing you want is to have to wait. Einstein Analytics is designed with speed and usability in mind, so that from the moment you turn it on, you’ll be gathering, analyzing, and employing valuable data. After all, the data stream isn’t going to wait for you. Trust the analytics solution that eliminates analytics down time, and start putting your data to work for you from day one.Connect Across Departments.
  8. Integrate with the entire Salesforce ecosystem: Salesforce Einstein Analytics is a core component of the Salesforce Customer Success Platform, and integrates perfectly with Sales Cloud, Service Cloud, Marketing Cloud, and Platform (to name a few), giving every team access to the same client data, for a seamless customer journey across every department.
  9. Easily explore customer data from every source: Gather and investigate data from any source, giving your team an hyper-detailed look at the numbers that matter.
  10. Bring your people togetherConnect sales, service, marketing, and every other team through cloud-based data analytics that can be accessed and collaborated on by authorized users across every department.
  11. Unify your goals: Give your teams a united vision and objectives they can strive for, with data that is insightful, reliable, and actionable.
  12. Collaborate from the dashboard: Make collaboration simple by working with other colleagues over a user-friendly interface that displays relevant information updated in real time.
  13. Generate presentation-worthy visuals: Use built-in tools to turn data insights into appealing and informative visuals, perfect for presentations. With Einstein Analytics, everyone in your organization can keep up with the numbers.
  14. Be a part of the conversation: Take advantage of social media technology to improve team communication, with Salesforce Chatter for Einstein Analytics.
  15. Put it all into context: Provide a consistent view across every department with embedded dashboards, so reliable analytics information is never more than a click away.
  16. Never be out of reach: Work with your teams and your data over any device, from anywhere in the world, thanks to mobile-first design compatible with any desktop, laptop, or mobile device.Salesforce Einstein Analytics gives you and your teams the power to turn data analysis into a team effort. Connect with your people over user-friendly dashboards to explore data in real time. Jump on social feeds to discuss findings and share insights. Access collaborative tools over mobile devices. Einstein Analytics makes it possible for you and your teams to put their heads together for data solutions that lead to success.Analyze Your Business.
  17. See team performance: Use real-time, easy-to-follow reports to chart team performance with Service Wave Analytics, identifying and improving trouble areas before they get out of hand.
  18. Access relevant KPIs: Access Sales Analytics to explore key performance indicators, such as quota attainment, sales cycle, pipe generation, and more, across your entire organization, to ensure your strategy is always right on target.
  19. Track call-center efficiency: See trends related to your customer support channels right on your home dashboard, so you can make informed decisions to promote better client services.
  20. Chart changes: Track team performance across extended timelines and more easily see patterns, dips, and upcoming opportunities.
  21. Become a better coach: Use detailed overviews of teams and individual employees to offer guidance and trainingwhere needed.
  22. Empower your teams to analyze themselves: Give your teams the power to benchmark their performance against top performers.
  23. Eliminate the holes in your campaigns: Perform whitespace analysis to identify and close up the gaps in your strategy.Salesforce Einstein Analytics gives you the ability to put your business under the microscope. Chart progress, rate performance, and shore up weaknesses in real time, thanks to cloud-based dashboards and visually rich reports. Get a bird’s-eye view of your entire operation, or get up close and personal with individual data sets. With Einstein Analytics, the data that drives your business is always at your fingertips.Find the Key to Sales Success.
  24. See the big picture: Explore all the data relevant to your sales operations in a single location via the Sales Executive Dashboard
  25. Eliminate borders: See your business across geographies, products, customer demographics, and time periods, for atrue view of how your sales are progressing.
  26. Find the devil in the details:Increase win rates by digging down deep into the specifics of your sales pipeline.
  27. Predict the futureChart historical trends to accurately forecast which strategies are likely to be most effective with which leads. Additionally, employ the Salesforce Einstein AIfor automated predictive accuracy that improves over time.
  28. Reduce churn: Get detailed insights into the motivations, preferences, and goals of each individual customer, ensuring personalized customer journey that is more likely to lead to conversion.
  29. Focus on the right leadsAnalyze your prospects to see which are the most likely to convert, and which are not.
  30. Evaluate your lead sources: See which sources result in the most valuable leads, so you can better focus your efforts where they’re going to pay off.
  31. Recognize your biggest wins: See your top-five closed deals, so that you can set standards that lead to real improvement.
  32. Optimize the customer experience: Solve issues and track client satisfaction by the numbers, directly from the Salesforce platform, for happier clients and better returns across the board.Understand key performance drivers, recognize emerging trends, predict future events, and more. Optimize your pipeline, and give your sales associates the information they need to provide their customers with the best possible experience. Salesforce Einstein Analytics gives your sales team the power to turn data into insight, and insight into profit.Market Smarter.
  33. Dive deeper: Get to the heart of your marketing data, with detailed analysis of funnels, campaigns, lead conversion rates, and even the marketing channels themselves.
  34. Present the right messageCreate messaging to spire and entice your target audience, and get valuable insight into the individuals who make up that audience.
  35. Be your own data analyst: Marketing data analysis is too important to place in someone else’s hands. Become your own marketing analyst, with easy-to-use tools and clear, visually-focused reports.
  36. Take instant action: Strike while the iron is hot, and act upon up-to-the-minute marketing data from centralized dashboards and control panels.
  37. Make B2B marketing your speciality: Take advantage of unique and effective B2B marketing tools to get ahead of the competition.
  38. Understand the brand experience: Use reliable data to see what your clients see, and make positive changes with the customer experience as your key focus.The data that drives marketing campaigns is generally very complex, but that doesn’t mean that it should be confusing. Salesforce Analytic Cloud gives you the insight you need to get behind the data, and see what’s driving your business, what’s guiding your customers, and how your business can turn that information into real results.Optimize Service.
  39. Set your priorities: Use service manager to prioritize open cases, so that the your teams always have a direct view of which customers need their attention.
  40. Evaluate your accountsQuickly identify which accounts have the largest number of cases and highest opportunity amount.
  41. Connect with your agents: Access the dashboard and see at a glance which agents are responsible for which cases, then assign notifications for when specific conditions are met.
  42. Review your service backlogCompare relevant data, to identify service trends over time, and see how totals compare between years.Service is what keeps you clients coming back for more. Give your teams the tools to provide the levels of high-quality service that your customers expect, and then go above and beyond. Analytics cloud empowers you to optimize service.Revolutionize Analytics for Your Business.
  43. Integrate with third-party applications: Extend your analytics aptitude beyond the Salesforce core systems, with advanced integration options for any third-party website.
  44. Go mobile: Act on data wherever you are, with mobile access to every aspect of the Salesforce platform. Search resources, review vital data, and optimize your various campaigns all from your mobile smart device.
  45. Optimize your pipelines: Embrace top, data-driven strategies for managing your pipeline.
  46. Automate your analysis efforts: Salesforce Einstein AI is designed to automatically analyze millions of data combinations, for results that are as informed as they are extensive.
  47. Enjoy the highest level of data security: Share data across any device from anywhere, comfortable in the knowledge that Salesforce Einstein Analytics uses the same cloud security best practices as the core Salesforce Customer Success Platform, trusted by more than 150,000 businesses worldwide.
  48. Push the limits: Extend your analytics abilities through custom-made applications, courtesy of app development tools from Salesforce Platform. Or, find the perfect ready-made app to fill your specific analytics needs, available from the Salesforce AppExchange.
  49. Gain deeper visibility into your businessCombine Einstein Analytics with Lightning Reports, for a completely transparent view of your most important data.
  50. Keep up the pace: Don’t let yourself get slowed down by having to work with data spread thin across your organization. Abandon the spreadsheets and cut your dependence upon IT, and let Salesforce Einstein Analytics consolidate your data in a single, central location, so that your business is as dynamic as the data that powers it.                                                                                                                                                                                                                                                                                                                                                      – Sumanth A[01/04/19]

Lightning Action Icons

A Lightning:Icon is a visual element that provides context and enhances usability. Icons can be used inside the body of another component or on their own.

There are some basic icons which displays various action icons that can be used on a Lightning Components.

Below is the sample code for displaying the action icons in order:

Code:

<aura:component> 
<lightning:icon iconName="action:approval" alternativeText="Approved" />
<lightning:icon iconName="doctype:audio" alternativeText="Audio file" />
<lightning:icon iconName="standard:event" alternativeText="Event" /> <lightning:icon iconName="utility:connected_apps" alternativeText="Connected" />
<lightning:icon iconName="utility:warning" alternativeText="Warning!" variant="warning"/>
<lightning:icon iconName="utility:error" alternativeText="Error!" variant="error"/>
<lightning:icon iconName="utility:image" alternativeText="Utility image" />
<lightning:icon iconName="doctype:image" alternativeText="Doc image" /> </aura:component>

Ranjith T [12/19/2018]

Custom Data Table With Pagination And Checkbox Functionality In Salesforce Lightning

In this post I am  going to show how we can create custom lightning data table with client side JavaScript pagination buttons and row level checkbox functionality using salesforce lightning component. In this component we’ll also persist checkbox checked state on pagination.

 
Apex Controller : dataTableCtrl
public class dataTableCtrl{
    @AuraEnabled
    public static List<accountListWrapper> fetchAccountWrapper(){     
        List<accountListWrapper> lstaccountListWrapper = new List<accountListWrapper>();
        // query account records and create 'accountListWrapper' class instance for each record. 
        for(Account acc : [Select id,Name,Type,Phone
                           From Account
                           Limit 1000]){
                               // by default checkbox should be false 
                               lstaccountListWrapper.add(new accountListWrapper(false,acc));
                           }
        // return the 'lstaccountListWrapper' list 
        return lstaccountListWrapper;
    }
    
    /* wrapper class */  
    public class accountListWrapper {
        @AuraEnabled public boolean isChecked {get;set;}
        @AuraEnabled public  account objAccount{get;set;}
        public accountListWrapper(boolean isChecked, account objAccount){
            this.isChecked = isChecked;
            this.objAccount = objAccount;
        }
    }
}
 
Lightning Component
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
access="global"
controller="dataTableCtrl">
<!-- call doInit method on component load -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<!-- aura attributes to store data/values -->
<aura:attribute name="listOfAllAccounts" type="list"/>
<aura:attribute name="PaginationList" type="list"/>
<aura:attribute name="selectedCount" type="integer" default="0"
description="selected Records Count"/>
<aura:attribute name="startPage" type="Integer" />
<aura:attribute name="endPage" type="Integer"/>
<aura:attribute name="totalRecordsCount" type="Integer"/>
<aura:attribute name="pageSize" type="Integer" default="4"
description="number of records to be display on per page"/>
<aura:attribute name="currentPage" type="integer" default="1"/>
<aura:attribute name="totalPagesCount" type="integer"/>
<aura:attribute name="bNoRecordsFound" type="boolean"/>
<aura:if isTrue="{!v.bNoRecordsFound}">
<!--display error message if there is no records available -->
<div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_info" role="alert">
<span class="slds-assistive-text">error</span>
<h2>No record found.</h2>
</div>
<aura:set attribute="else">
<!-- lightning:button to get selected rows data -->
<div class="slds-clearfix slds-m-around_small">
<div class="slds-clearfix">
<div class="slds-float_right">
<lightning:button variant="destructive"
label="Get Selected Records"
onclick="{! c.getSelectedRecords }"
disabled="{!v.selectedCount == 0}"/>
</div>
</div>
</div>
<!-- display total record and selected record count -->
<p class="slds-m-around_small">
<span class="slds-badge slds-badge_lightest" style="display:inline-block">
Total Records : {!v.selectedCount > 0 ? v.selectedCount + '/' : ''} {!v.totalRecordsCount} 
</span>
</p>
 
<!-- data table start-->
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<thead>
<tr class="slds-text-title_caps">
<!--header checkbox for select all-->
<th style="width:3.25rem;" class="slds-text-align_right">
<div class="slds-form-element">
<div class="slds-form-element__control">
<label class="slds-checkbox">
<ui:inputCheckbox disabled="{!v.totalRecordsCount == 0}"
aura:id="selectAllId"
change="{!c.selectAllCheckbox}"/>
<span class="slds-checkbox_faux"></span>
<span class="slds-form-element__label"></span>
</label>
</div>
</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Name">Name</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Phone">Phone</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Type">Type</div>
</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.PaginationList}" var="obj">
<tr>
<th scope="row" class="slds-text-align_right" style="width:3.25rem;">
<div class="slds-form-element">
<div class="slds-form-element__control">
<label class="slds-checkbox">
<ui:inputCheckbox text="{!obj.objAccount.Id}"
value="{!obj.isChecked}"
change="{!c.checkboxSelect}"/>
<span class="slds-checkbox_faux"></span>
<span class="slds-form-element__label text"></span>
</label>
</div>
</div>
</th>
<th scope="row">
<div class="slds-truncate" title="{!obj.objAccount.Name}">
                                    {!obj.objAccount.Name}
</div>
</th>
<th scope="row">
<div class="slds-truncate" title="{!obj.objAccount.Phone}">
<lightning:formattedPhone value="{!obj.objAccount.Phone}"/>
</div>
</th>
<th scope="row">
<div class="slds-truncate" title="{!obj.objAccount.Type}">
                                    {!obj.objAccount.Type}
</div>
</th>
</tr>
</aura:iteration>
</tbody>
</table>
<!-- DataTable End -->
<br/>
<!--  Pagination Buttons Start -->
<div class="slds-align_absolute-center">
<lightning:button label="Previous"
disabled="{!v.startPage == 0}"
onclick="{!c.navigation}"
variant="brand"
iconName="utility:back"
name="previous"/>
<span class="slds-badge slds-badge_lightest"
style="margin-right: 10px;margin-left: 10px;">
                    Page {!v.currentPage} out of {!v.totalPagesCount}
</span>
<lightning:button label="Next"
disabled="{!(v.endPage + 1) >= v.totalRecordsCount}"
onclick="{!c.navigation}"
variant="brand"
iconName="utility:forward"
iconPosition="right"
name="next"/>
</div>
<!--  Pagination Buttons End -->
</aura:set>
</aura:if>
</aura:component>
 
Java Script Controller
 
({
doInit: function(component, event, helper) {
helper.doInitHelper(component, event);
},
 
/* javaScript function for pagination */
navigation: function(component, event, helper) {
var sObjectList = component.get("v.listOfAllAccounts");
var end = component.get("v.endPage");
var start = component.get("v.startPage");
var pageSize = component.get("v.pageSize");
var whichBtn = event.getSource().get("v.name");
// check if whichBtn value is 'next' then call 'next' helper method
if (whichBtn == 'next') {
component.set("v.currentPage", component.get("v.currentPage") + 1);
helper.next(component, event, sObjectList, end, start, pageSize);
}
// check if whichBtn value is 'previous' then call 'previous' helper method
else if (whichBtn == 'previous') {
component.set("v.currentPage", component.get("v.currentPage") - 1);
helper.previous(component, event, sObjectList, end, start, pageSize);
}
},
 
selectAllCheckbox: function(component, event, helper) {
var selectedHeaderCheck = event.getSource().get("v.value");
var updatedAllRecords = [];
var updatedPaginationList = [];
var listOfAllAccounts = component.get("v.listOfAllAccounts");
var PaginationList = component.get("v.PaginationList");
// play a for loop on all records list 
for (var i = 0; i < listOfAllAccounts.length; i++) {
// check if header checkbox is 'true' then update all checkbox with true and update selected records count
// else update all records with false and set selectedCount with 0  
if (selectedHeaderCheck == true) {
listOfAllAccounts[i].isChecked = true;
component.set("v.selectedCount", listOfAllAccounts.length);
} else {
listOfAllAccounts[i].isChecked = false;
component.set("v.selectedCount", 0);
}
updatedAllRecords.push(listOfAllAccounts[i]);
}
// update the checkbox for 'PaginationList' based on header checbox 
for (var i = 0; i < PaginationList.length; i++) {
if (selectedHeaderCheck == true) {
PaginationList[i].isChecked = true;
} else {
PaginationList[i].isChecked = false;
}
updatedPaginationList.push(PaginationList[i]);
}
component.set("v.listOfAllAccounts", updatedAllRecords);
component.set("v.PaginationList", updatedPaginationList);
},
 
checkboxSelect: function(component, event, helper) {
// on each checkbox selection update the selected record count 
var selectedRec = event.getSource().get("v.value");
var getSelectedNumber = component.get("v.selectedCount");
if (selectedRec == true) {
getSelectedNumber++;
} else {
getSelectedNumber--;
component.find("selectAllId").set("v.value", false);
}
component.set("v.selectedCount", getSelectedNumber);
// if all checkboxes are checked then set header checkbox with true   
if (getSelectedNumber == component.get("v.totalRecordsCount")) {
component.find("selectAllId").set("v.value", true);
}
},
 
getSelectedRecords: function(component, event, helper) {
var allRecords = component.get("v.listOfAllAccounts");
var selectedRecords = [];
for (var i = 0; i < allRecords.length; i++) {
if (allRecords[i].isChecked) {
selectedRecords.push(allRecords[i].objAccount);
}
}
alert(JSON.stringify(selectedRecords));
}
})
 
Java Script Helper
 
({
/* doInitHelper funcation to fetch all records, and set attributes value on component load */
doInitHelper : function(component,event){
var action = component.get("c.fetchAccountWrapper");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS"){
var oRes = response.getReturnValue();
if(oRes.length > 0){
component.set('v.listOfAllAccounts', oRes);
var pageSize = component.get("v.pageSize");
var totalRecordsList = oRes;
var totalLength = totalRecordsList.length ;
component.set("v.totalRecordsCount", totalLength);
component.set("v.startPage",0);
component.set("v.endPage",pageSize-1);
var PaginationLst = [];
for(var i=0; i < pageSize; i++){
if(component.get("v.listOfAllAccounts").length > i){
PaginationLst.push(oRes[i]);
}
}
component.set('v.PaginationList', PaginationLst);
component.set("v.selectedCount" , 0);
//use Math.ceil() to Round a number upward to its nearest integer
component.set("v.totalPagesCount", Math.ceil(totalLength / pageSize));
}else{
// if there is no records then display message
component.set("v.bNoRecordsFound" , true);
}
}
else{
alert('Error...');
}
});
$A.enqueueAction(action);
},
// navigate to next pagination record set   
next : function(component,event,sObjectList,end,start,pageSize){
var Paginationlist = [];
var counter = 0;
for(var i = end + 1; i < end + pageSize + 1; i++){
if(sObjectList.length > i){
if(component.find("selectAllId").get("v.value")){
Paginationlist.push(sObjectList[i]);
}else{
Paginationlist.push(sObjectList[i]);
}
}
counter ++ ;
}
start = start + counter;
end = end + counter;
component.set("v.startPage",start);
component.set("v.endPage",end);
component.set('v.PaginationList', Paginationlist);
},
// navigate to previous pagination record set   
previous : function(component,event,sObjectList,end,start,pageSize){
var Paginationlist = [];
var counter = 0;
for(var i= start-pageSize; i < start ; i++){
if(i > -1){
if(component.find("selectAllId").get("v.value")){
Paginationlist.push(sObjectList[i]);
}else{
Paginationlist.push(sObjectList[i]);
}
counter ++;
}else{
start++;
}
}
start = start - counter;
end = end - counter;
component.set("v.startPage",start);
component.set("v.endPage",end);
component.set('v.PaginationList', Paginationlist);
},
})

-Ranjith T [12/19/18]

Salesforce lead Queues

In Salesforce, Queues allow for management and organization of records in Leads, Cases, and custom objects. Lead Queues are particularly helpful because they allow you to funnel a group Leads into a queue based on a particular criteria whereby users in that queue can claim ownership of those Leads. For example, you can create a Lead Queue to distribute newly created Leads or those captured from web by region/territory (West Coast, North Pacific…etc) Today, I’ll be giving an introduction on how to create a Leads Que.

CREATING REGIONS/TERRITORIES:

First, we’re going to create a queue for each region.

To get started, go to Setup> Administration Setup> Manage Users> Queues and click New.
Name the Queue and optionally, you can assign an email address specific for the queue; users in that queue will receive updates on actions.
Next, pick the object you want to create the queue in.

Next, assign users to the queue. Alternatively, you can assign a Group of users to a queue. Then click Save.

ASSIGNING RULES FOR LEAD QUEUES

Now that you’ve built the queue, it’s time to create rules to automatically assign users to the appropriate region/territory queue. Go to Setup> Customize> Leads> Assigning Rules and click “New”. In Assignment Rules, you can prioritize the order of rules.Assigning Rules will run on an ascending order.

First, set the order of the rule.

Enter the criteria on which you want the Assignment Rule to apply
If you have multiple rules and depending on the logic, you can modify the logic of the rules right under the list.

Finally, enter the name of the queue you want the records with the above criteria to go to. click Save.

And now, users assigned to the queue can have a list view of all records in that queue where they can assign ownership accordingly. Only those users and users of higher hierarchy will have access to that list view.

Chandra V [11/26/2018]

Force Refresh on Lightning Component

To Force Refresh on a Lightning Component this code can be used:

refresh : function(component, event, helper) {
var action = cmp.get(‘c.myController’;);
action.setCallback(cmp,
function(response) {
var state = response.getState();
if (state === ‘SUCCESS’){
$A.get(‘e.force:refreshView’;).fire();
} else {
//do something
}
}
);
$A.enqueueAction(action);
}

Reloads the view.

To refresh a view, run $A.get(“e.force:refreshView”;).fire();, which reloads all data for the view.

This example refreshes the view after an action is successfully completed

Yeshas [11/10/18]