Saturday, 7 November 2020

CLI Data Loader - Salesforce

Prerequisite: Install Java and Dataloader.

Step 1: Prepare your key for encrypting the password of your org:

·                        Open the command prompt window, and navigate to the bin folder of data loader directory

·                        Use the command encrypt.bat -k .



·                        Once you will hit enter, it will generate the keyfile and shows the location. Copy the link for further use and paste it somewhere.

 


         encrypt.bat -e July2020@9vZcKyrv8IyCDiRfP39xCLgT "C:\Users\iAnil\.dataloader\dataLoader.key"

         Add password+token of the sandbox/org and add the link of KeyFile.


          Hit enter then it will generate encrypted password for your org. Copy it paste it somewhere. It will be used in CLI Script.

          Create DataLoaderFiles folder or create a folder with your name choice outside Program Files folder. In my case I have created in C drive. Path is C:\DataLoaderFiles.

      Step 2: Prepare your mapping file:

      Create the mapping file by putting the CSV file header name on left side and Salesforce API name on right side. Move the mapping file to  C:\DataLoaderFiles location. I have used the below sdl file for extracting account.



    Step 3: Prepare your process-conf:

·                    Create the process-conf file to  C:\DataLoaderFiles location. (xml file)

·                    Edit the file and enter your information.

sfdc.endpoint – Production URL/Sandbox URL.

sfdc.username – Your username from the org.

sfdc.password – Encrypted password, created in earlier steps.

process.mappingFile – Specify path of mapping file.

dataAccess.name - Specify path of csv file.

process.outputSuccess – Specify path where you want success file

process.outputError – Specify path where you want error file



Step 4: Prepare your bat file:

·                 Create txt file and save it with .bat extension in Dataloader bin folder



Specify path of the process-conf file and name of process-conf in batchable file.

 

Step 5: Schedule batch file with windows scheduler:

·                 Schedule the batch file with task scheduler as per your required time to insert the data.

Note : Once this process completed, data will be inserted into Account object.

    

Wednesday, 9 September 2020

Create a New Opportunity From a Quick Action - Salesforce

Requirement Statement: 

"Opportunity should be created from Account page layout by using 'New Opportunity' button and while creating it should ask for record type selection option and also it should pre-populate Account Name."


Solution Approach: 

Create a custom button on Account to create Opportunity as below.

 While creating button, it will ask for Record Type to select, but the issue is that you can select only one record type. 

So, you need to create 4 custom buttons for one for each record type as I have in my org. Later you need to add these multiple custom buttons on page layout as well.

This is not the right solution approach/UI Experiece/best practice to follow. 


Solution: 

Here is solution that exact match to out requirement. Create 'Custom Button or Link' on Account as below. 

Refer the URL -

/lightning/o/Opportunity/new?useRecordTypeCheck=1&defaultFieldValues=AccountId=!Account.Id}

Parameters to remember:

1. useRecordTypeCheck=1

This will enable for the record type selection option. 

2. defaultFieldValues=AccountId={!Account.Id}

This will prepopulate Account Name on Opportunity from Account. If you want to add more fields just add '&' and add fields.
Example: defaultFieldValues=AccountId={!Account.Id}&StageName='Plan'

Then finally save and add it to page layout.

Now go to any Account record and Click on 'New Opportunity'.
 

Select the record type and click 'Next'
You can see pre-populated Account Name.

Note: Just change object name/fields as per your requirement.

This is only available for LEX, not available for Mobile.

If you like it, subscribe for more blogs and comment for feedback to motivate.
Happy Learning!!!