Tuesday, May 12, 2020

Navigate to Visualforce page from lightning web components(lwc)

To navigate to visualforce page we have to use the Navigation Service in Lightning web components.

Check below for more details about navigation service in Lightning web components

Sample Code

//Navigate to visualforce page
navigateToVFPage() {
	    type: 'standard__webPage',
	    attributes: {
		    url: '/apex/SampleVFPage?id=' + recId
    }).then(vfURL => {

Tuesday, May 5, 2020

How to deploy sharing rules using ANT tool in Salesforce



Monday, May 4, 2020

How to format Dates in lightning web components(lwc) using JavaScript

To format the javascript dates in custom formats we need to use the DateTimeFormat
The Intl.DateTimeFormat object is a constructor for objects that enable the language-sensitive date and time formatting.

Sample Code
let dt = new Date();
const dtf = new Intl.DateTimeFormat('en', {
    year: 'numeric',
    month: 'short',
    day: '2-digit'
const [{value: mo}, , {value: da}, , {value: ye}] = dtf.formatToParts(dt);

let formatedDate = `${da}-${mo}-${ye}`;
console.log('formatedDate ===> '+formatedDate);


Saturday, May 2, 2020

Convert Seconds to hours and minutes(hh:mm:ss) using apex in salesforce

Sample Code
Integer seconds = 7249;
System.debug('Converted format => '+DateTime.valueOf(seconds*1000).formatGMT('HH:mm:ss'));