The 'Days_Since_Last_Update__c' formula field did not return the correct number of days between an Account’s Last Activity Date and today

Use the below formula

TODAY() - Account.LastActivityDate


Cheers!!!

When to use Formula field in Salesforce?

1. To create a percentage from 2 numeric fields.

2. To create a clickable hyperlink for easy access to important information from a record’s page layout.

3. To calculate the number of days between two dates.

Cheers!!!

What is the difference between 15 digit and 18 digit IDs in Salesforce?

15 Digit Id is case-sensitive whereas 18 Digit Id is case-insensitive.

Many legacy applications doesn't support case sensitive strings, so in that case we can make use of 18 digit Id which is case in-sensitive.

15 digit or 18 digit depends upon your requirement and dependent application.

API always makes use of 18 digit Id.

URL in Salesforce makes use of 15 digit Id.

Cheers!!!

Mobile Number validation using Apex in Salesforce

Sample Code:

String tempStr = '9999999999';

if(!Pattern.matches('[0-9]{10}', tempStr)) {                         
    //error msg
    system.debug('Testing');
}

Cheers!!!

How to undelete mass records in Salesforce?

1. Extract the ids of the records using data loader or any other tool.

2. Go to https://workbench.developerforce.com.

3. Use Undelete option under data menu.


Cheers!!!

Failed to load document issue in Salesforce

If you face "Failed to load document issue in Salesforce" issue, try the below code for attachment body.

Attachment att = new Attachment();
att.Body = Blob.toPDF(strVar);

Other troubleshooting steps are

1. Check the HTML formation.

2. Check whether the content type is assigned to the attachment.

3. Debug the body of the attachment.

Usually due to Blob.ValueOf(), we face "Failed to load document issue in Salesforce" issue.

Cheers!!!

sforce.one JavaScript Utility Object

sforce.one is automatically injected into your page when it runs in Lightning Experience. You’ll see it in your JavaScript debugger console and web developer resources list. There’s nothing you need to do to add it, and there’s no way to suppress it, either.

sforce.one is primarily used to fire navigation events.

Cheers!!!

SOQL Injection

SOQL Injection can occur in Apex code whenever your application relies on end user input to construct a dynamic SOQL statement and you do not handle the input properly.

To prevent SOQL injection, use the escapeSingleQuotes method. This method adds the escape character (\) to all single quotation marks in a string that is passed in from a user. The method ensures that all single quotation marks are treated as enclosing strings, instead of database commands.

Sample SOQL:

        String strText = 'Test';
        String SOQL = 'SELECT Id, Name FROM Account WHERE Name = \'' + String.escapeSingleQuotes(strText) + '\'';
        List<Account> listAcct = Database.query(SOQL);
        system.debug('test ' + listAcct);

Cheers!!!

Dynamic SOQL

Dynamic SOQL refers to the creation of a SOQL string at runtime with Apex code. Dynamic SOQL enables you to create more flexible applications. For example, you can create a search based on input from an end user, or update records with varying field names.

Sample SOQL:

String myString = 'TestName';

List<Account> acctList = Database.query('SELECT Id FROM Account WHERE Name = :myString');

Cheers!!!

How to pass parameters using PageReference in Salesforce?

First VF Page:

<apex:page controller="Sample">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >Enter the text to be passed: <apex:inputText value="{!strText}"/></apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:pageBlockButtons >
            <apex:commandButton value="Go to Next Page" action="{!nextPage}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
</apex:page>

public class Sample {
    public String strText {get;set;}
    public Sample() {
    }
 
    public PageReference nextPage() {
        PageReference pg = new PageReference('/apex/NextPage');
        pg.getParameters().put('str', strText);
        pg.setRedirect(false);
        return pg;
    }
}

Second VF Page:

<apex:page controller="NextPageController">
Value passed in previous page is {!strText}
</apex:page>

public class NextPageController {
    public String strText {get;set;}
    public NextPageController() {
        strText = ApexPages.currentPage().getParameters().get('str');
    }
}

Output:





Cheers!!!

Sales Path in Salesforce

Give your sales reps a visual guide in the Salesforce1 mobile app: Show them where they are in the sales process and what they need to do next to close the sale. Have multiple sales processes at your company? Create a Sales Path (one per record type) for each process.

To setup Sales Path, follow the below steps

1. Go to Setup --> Customize --> Sales Path --> Settings.


2. Enable it.


3. Click "New Sales Path".


4. Enter the Label and other information.


5. Add fields to each and every stage.


6. Click "Save".


7. Click "Finish".

To test the Sales path in the browser, follow the below steps

1. Add one/one.app to the end of the URL.

2. Select menu and select Opportunities.


3. Open an Opportunity to see the output.


Cheers!!!

no main manifest attribute, in svnstat-all.jar in statsvn

If you face no main manifest attribute, in svnstat-all.jar issue, download the latest svnstat.jar file from the below link and replace it with your old jar file.

http://www.statsvn.org/downloads.html

The latest jar file will fix that issue.

If the problem still persists, try to reboot your system.

Cheers!!!

How to get SVN commits reports using Tortoise SVN?

1. Check out the project using Tortoise SVN Checkout.. option.


2. Give the URL and select the Directory.


3. Right Click the checked out project and select Tortoise SVN --> Show Log.


4. Click "Statistics" button.


5. Select the different Graph type for the reports.


Cheers!!!

SVN is not recognized as an internal command

While installing Tortoise SVN, we should make sure that Command Line is selected. If it is not selected while installing we get SVN is not recognized as an internal command.

In order to fix this, download the latest Tortoise SVN and install it. While installing make sure that Command Line check box is selected.


Cheers!!!

How to create report from SVN commits?

1. Use the below link to download SVNStat application.

http://sourceforge.net/projects/statsvn/

2. Unzip the file.

3. Move it to any drive. In my case, I have moved it to D:\SVN.

4. Install Tortoise SVN client from http://tortoisesvn.net/downloads.html.

5. Check out the project by right click and SVN Checkout....


6. Select the correct branch and a local folder to check out the project.


7. Navigate to the checked out project folder in Command Prompt and create a SVN log file using the below command.

svn log --xml -v > svn.log

8. Navigate to SVN folder and execute the below command.

java -jar svnstat.jar D:\SVN\ProjectFolder\svn.log D:\SVN\ProjectFolder

9. Now go to SVN Folder (D:\SVN).

10. Several html files would have been created to see the statistics.

Cheers!!!

Formula field to show Current Date and Time in Salesforce

Formula Field:


Output:


Cheers!!!

How to find date difference in Visualforce page?

Sample Code:

<apex:page>
    <apex:outputText>
        {! EndDateVariable - StartDateVariable}
    <apex:outputText>
</apex:page>

Instead of creating formula fields, we can just subtract it in the Visualforce page.

Cheers!!!

Salesforce Marketing Cloud

To get started with Salesforce Marketing Cloud

http://code.exacttarget.com/getting-started/

To signup and work with Salesforce Marketing Cloud, use the below link

http://code.exacttarget.com/developer-edition/

For queries, check the below link

http://help.exacttarget.com/

Cheers!!!

When to use Bulk API instead of REST API in Salesforce?

REST API is used when the number of records are very less.

Bulk API is used when we are going to implement for large set of data. Bulk API also uses the same principles of REST API.

Cheers!!!