Wednesday, October 9, 2019

How to set and reset the password using Apex in Salesforce

This post explains how to set and reset the password using apex in salesforce

Reset Password

Demo
resetPassword method accepts two parameters
Id (UserId): Id of the user
Boolean: it represents the send email to user or not
System.resetPassword(Id.valueOf('005B0000005lewT'), true);
when you run the above code, salesforce sends a password reset link to the user

Set Password

Demo
setPassword method accepts the two parameters
Id (UserId): Id of the user
String: new password value.
System.setPassword(Id.valueOf('005B0000005lewT'), 'test@12345');
when you run the above code salesforce will set the new password to the user.

Introducing Local Development Server for Salesforce Lightning Web Components

This post explains local development in salesforce lightning web components(lwc)

Note: Currently, This feature is in beta stage

As a salesforce developer, we used to develop code in developer org/sandbox, to develop newly introduced lightning web components we are using vs code or other code editors which are support for lwc development.
Salesforce recommends the vs code editor. As we develop code in VS Code we need to push the code each and every time it's changed back to our Salesforce Org to test the changes. sometimes it will take a lot of time to push the code to salesforce.

Now salesforce introduced the local development option to build, run and test our component from Local server itself instead of deploying into Salesforce Org, salesforce made it easy for us to build the component and fix the errors in local itself before pushing to salesforce org and also we have the option to access Salesforce real-time data using LDS, UI API, and Apex.

The Local Development Server is a Salesforce CLI plugin that configures and runs a Lightning Web Components-enabled server on your computer. Now you can develop Lightning Web Component modules and see live changes without publishing your components to an org.

Prerequisites:
   1.  Install VS Code Editor 
   2.  Install Salesforce Extension Pack into Visual Studio Code
   3.  Install Salesforce CLI

Once install the prerequisites, configure the SFDX project in VS Code.
  1.  SFDX: Create Project
  2.  SFDX: Create Project with Manifest
  3.  SFDX: Authorize an Org

Follow the below steps to configure the Lightning Web Components with local development server (LWC dev server)
Step:1
Open a new terminal window and run the following command to install the local development server.
 sfdx plugins:install @salesforce/lwc-dev-server

Step:2
Check for updates to the local development server.
 sfdx plugins:update
Step:3
Once the plugin is installed you can run the Local Development Server on your Salesforce project by running the start command. Note that you will want to be authorized into an org before you start the server so you can take advantage of the data proxy features.
sfdx force:lightning:lwc:start

Now the local server is started, you can view the server at http://localhost:3333/

Tuesday, October 1, 2019

How to view deployed components in salesforce using Workbench

This post explains how to view deployed components using the workbench.

  • Login to workbench
  • Select Production/Sandbox(based on your preferences)
  • Give your login credentials and give allow access to a workbench
Then select "Metadata Process API Status"
It asks the AsyncProcessId then get you deployment Id
Then select Deploy and click on the Get Status button, it returns the deployed metadata components in org.