Hello Awesome Salesforce Developers ,
Few days ago, I got a requirement to calculate the elapsed time between Case open date and Case closed date.
There is standard formula of salesforce which will calculate the Date Difference (Field with datatype formula and return type text)
The above formula will calculate the difference in days, hours and minutes.
My requirement is to extend this formula to calculate the difference in days, hours, minutes and seconds.
Let's calculate it !!!
First will understand some factors about datetime.
1 Day = 24 Hours
24 Hours = 1440 Minutes
1440 Minutes = 86400 Seconds
Create a field with datatype formula and return type as Text. Use the below formula and you are set !!!!
FLOOR() - Used to round up to nearest integer.
ROUND() - Returns the nearest number to a number you specify.
Cheers !!!!
Hello Awesome Salesforce Developers ,
In one of my project I got following requirement :
1. Add custom button in list view.
2. User will select the list view and select the records from the list view and on the custom button click (added in step (1) ) user will be redirected to another page where he perform certain operation.
3. After operation is over then on click of another custom button on Visualforce page say "Return to List View" user should redirect to list view he selected in the step (2)
The challenging part in this task was to get selected list view as we need to redirect user to list view selected in previous step.
If you check the URL of any list view it is constructed as follows :
https://ajaytrailhead-dev-ed.my.salesforce.com/001?fcf=00B28000003fFfg
----------- Domain Name -------------------------/Object Prefix ? fcf= Id of the list view
"fcf" is the parameter used to identify the list view Id.
So you just need to construct the redirection URL in the above format.
Next question is from where we will get value for "fcf" parameter ?
Use Apexpages.currentpage.getParameters().get('fcf'); and you are set !
We got all the parameter now we just need to form the redirect URL explained in the following class.
The associated Visual force page :
The custom button code
Add above custom button to Search Layout --> Account List View.
Cheers !!!
Hi Salesforce folks ,
Many times you get a request to parse the contents of csv file and create records in salesforce objects.
In this blog I am going to demonstrate you how the parse the csv file using Apex.
Before starting the Apex code I would like to give you information about csv file
What is a csv file ?
CSV file having records as comma separated values.It stores the tabular data in plain text. Each line in the file is a record.
How the data is structured in the csv file ?
There are various formats of saving data to the csv file for example
"Name", "Address" => Header Row
"Ajay","Pune" => Data
"Ajay","Talegaon,Pune" => You may get data like this : Nested inside the "" with comma(,)
You can just google it for the various formats.
In the below snippet I am parsing the csv file and creating records in the Account salesforce object.
Assumption : You got csv file data in a string format. If you are getting data in blob format then you can convert it to string using string.valueof function.
Pass the string value to the below function and take a cup of tea !!!! :)
You can enhance the above code by adding exception handling of your choice.
Limitation :
The above code will work for 10000 records.(Standard Salesforce DML Limit).
You can overcome this limit by writing batch class. Send records to batch class for further processing.
Many more blogs are coming soon !!!
Stay connected !!!
Cheers !!