How to find 9th Character from a string using JAVASCRIPT?

Sample Code:

var value = '11111111911;
String s = value.charAt(8); //return 9

Note: Index starts at 0.

Cheers!!!

DML operation giving undefined Salesforce Lightning

Check the debug log.

If the DML operation is failed, we get "Undefined" error.

Cheers!!!

Unable to read sobject Salesforce Lightning

Sample Code:

<aura:attribute name="SampleName" type="NameSpacePrefix__ObjectAPIName"
default="{ 'sobjectType':'NameSpacePrefix__ObjectAPIName',
'Name':'',
'NameSpacePrefix__FieldAPIName': 0,
'NameSpacePrefix__FieldAPIName':'',
}"/>

Cheers!!!

How to use multiple methods inside js controller lightning?

Sample Code:

({
storeTest : function(component, event, helper) {

},

    getTest : function(cmp, event) {
        //
},

    getTest1 : function(cmp, event) {
        //
    }
})

The methods should be separated ','.

Cheers!!!

Something has gone wrong. Cannot read property 'get' of undefined

Make sure get() in the JAVASCRIPT doesn't having undefined value. Check the condition before using get().

Sample Code:

var contractNo = component.find("contractNo");
var contractNoValue = contractNo.get("v.value")

In the above code, there should be a component with id "contractNo", else we will get this error.

Cheers!!!

How to use Lightning Component in Lightning Builder?

Add implements="flexipage:availableForAllPageTypes" access="global" to the aura:component tag to use Lightning Component in Lightning Builder.

Cheers!!!

How to pass Record Type selection to override page in Salesforce?

Sample code:

String recordTyp = ApexPages.currentPage().getParameters().get('RecordType');
if ( String.isNotBlank(recordTyp) )
p.getParameters().put('RecordType',recordTyp);

Cheers!!!

Validation rule for component in Salesforce Lightning

Sample Code:
Component:

<aura:component >
<ui:inputNumber label="Contract No " aura:Id="contractNo" blur="{!c.validateContractNo}"/>
</aura:component>

Controller:

({
validateContractNo : function(component, event, helper) {
var inputCmp = component.find("contractNo");
var value = inputCmp.get("v.value");
        
        if ( value.length < 8 || value.length > 12 || isNaN(value) ) {
            inputCmp.set("v.errors", [{message:"Invalid Contract No: " + value}]);
        } else {
        inputCmp.set("v.errors", null);
        }
}
})

Cheers!!!

Label is not showing lightning application Salesforce?

The attribute should be label. It should not be Label.

Make the attribute names in small letters. Don't capitalize the first character.

Cheers!!!

How to use Lightning Component in Lightning Application?

Sample Code:

<aura:application >
    <c:ContractNumber/>
</aura:application>

here ContractNumber is the name of the Lightning Component.

Cheers!!!

How to open Lightning Application in a Browser?

Sample URL:

https://infallibletech-dev-ed.lightning.force.com/InfallibleTech/MyLightningApp.app

Syntax:

https://instance.lightning.force.com/NameSpacePrefix/AppName.app

Cheers!!!

How to create text box in Salesforce Lightning Component?

Sample Code:

<ui:inputText label="Contract No" aura:id="contractNo"/>

Cheers!!!

How to connect to TFS from Eclipse?

1. Go to Window --> Perspective --> Open Perspective --> Other.


2. Select Team Foundation Server Exploring and click Ok.


3. Click "Connect to Team Services or a Team Foundation Server".


4. Click Servers.


5. Click Add.


6. Enter the URL of the Server.

7. Enter the username and password when it prompts.

8. Accept the License.

Cheers!!!

AuraError: Invalid component tried calling function { get } with arguments [ v.inContextOfComponent ]

This is a know issue.

Check the below link

https://developer.salesforce.com/forums/?id=906F0000000AvH7IAK

Raise a Salesforce.com support ticket to know more.

Cheers!!!

How to login into Sandbox in Salesforce1 Google Chrome extension?

Install Salesforce1 Sanbox Simulator App from Google Chrome extension.


Cheers!!!

Flow Triggers not available

For new Salesforce Organization, Flow Triggers are not available.

The best alternative for Flow Triggers is Process Builder.

Process Builder takes care of what Flow Triggers do.

Process Builder - http://www.infallibletechie.com/2015/10/process-builder-in-salesforce.html

Cheers!!!

Salesforce1 Simulator

1. Go to Settings.


2. Click "Get More Extensions".


3.Search Salesforce1 Simulator and add it.


Output:


Cheers!!!

App Builder for Lightning Experience

We can use the App Builder to create and edit record home pages in the new Salesforce Lightning Experience. Creating and editing Lightning Experience pages is in pilot. After we enable this feature, an "Edit Page" link appears in the quick access menu for record home pages in Lightning Experience.

1. Go to "Lightning App Builder".


2. Check Enable App Builder for Lightning Experience(PILOT).


3. Click "New" in Lightning Pages.


4. Select App page for mobile and Record Page for Desktop. I have used App Page in this example.


5. Select the Template. I have selected Two Column in this example.


6. Set your Page Properties and click "Finish".


7. Drag and Drop Recent Items.


8. Drag and Drop Rick Text.


9. Click Save and Activate.

10. Open your Salesforce1 App or Google Chrome Salesforce1 Simulator to test it.


Cheers!!!

How to use email template without targetobjectid?

Sample Trigger:

trigger EmployeeTrigger on Employee__c (after insert, after update) {
    Contact con = [ SELECT Id FROM Contact WHERE Email != null LIMIT 1];
    List < Messaging.SingleEmailMessage > listMsgs = new List < Messaging.SingleEmailMessage > ();
    for ( Employee__c e : trigger.new ) {
        Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
        msg.setWhatId(e.Id);
        msg.setTemplateId('00XU00000011sTd');
        msg.setToAddresses(new List < String > {'test30@gmail.com'});
        msg.setTreatTargetObjectAsRecipient(false);
        msg.setTargetObjectId(con.Id);
        listMsgs.add(msg);
    }    
    Messaging.sendEmail(listMsgs);
}

Cheers!!!

How to install TFS plugin in Eclipse?

1. Go to Help --> Install New Software.


2. Click "Add".


3. In Name, enter TFS Plugin for Eclipse and in Location, enter http://dl.microsoft.com/eclipse/tfs, and then choose OK.


4. Click "Next".


5. Click "Next".

6. Accept the Agreement.

7. Click "Finish".

8. Restart the Eclipse.

Cheers!!!

How to quick deploy using Apache ANT tool for Salesforce?

Sample Package.xml:

    <target name="quickdeployprod">
        <sf:deployRecentValidation       
        username="${sf.username}"
        password="${sf.password}"
        serverurl="${sf.sandboxurl}"
        recentValidationId = "
recently validated id"
        deployroot="Retrieve"/>
    </target>


Cheers!!!

How to validate using Apache ANT tool for Salesforce?

Sample Package.xml:

    <target name="validateprod">
        <sf:deploy       
        username="${sf.fusername}"
        password="${sf.password}"
        serverurl="${sf.sandboxurl}"
        checkOnly=true
        deployroot="Retrieve"/>
    </target>


Cheers!!!

Running Territory rule using Apex in Salesforce

It is not yet available in Salesforce.

Please vote for the below idea

https://success.salesforce.com/ideaview?id=08730000000BqRXAA0

Cheers!!!

Inline editing is not working in override in Salesforce

Inline editing will not work in override in Salesforce.

In order to fix this, override View with Visualforce page where inlineEdit can be set to true in apex:detail tag.

Please vote the below Idea so that it can be delivered by Salesforce just in case

https://success.salesforce.com/ideaView?id=08730000000Bq3Q

Cheers!!!

How to check whether a Salesforce site is Online or Offline using JAVASCRIPT?

1. Copy the below code in a notepad and save using.html extension.

<p><strong>Enter the website url below and click Check button to get the status of the server</strong></p>

<p>http:// <input type='text' id='sitehost'/> <input type='button' id='checkhost' value='Check'/></p>

<script type='text/javascript'>
function isSiteOnline(url,callback) {
    // try to load favicon
    var timer = setTimeout(function(){
        // timeout after 5 seconds
        callback(false);
    },5000)

    var img = document.createElement("img");
    img.onload = function() {
        clearTimeout(timer);
        callback(true);
    }

    img.onerror = function() {
        clearTimeout(timer);
        callback(false);
    }

    img.src = url+"/favicon.ico";
}

document.getElementById('checkhost').onclick = function() {
    isSiteOnline("http://"+document.getElementById('sitehost').value,function(result){
        var msg = result ? "Site is online" : "Site is offline";
        alert(msg);
    })
}

</script>

2. Enter any website URL and click Check button to check the status.

Cheers!!!

How to find whether Salesforce Server is up or down?

Option 1: Go to www.trust.salesforce.com

Option 2:

1. Go to http://www.isitdownrightnow.com/salesforce.com.html

2. In the right corner enter servername.salesforce.com.

3. Click "Check" button.

Cheers!!!