Tag Archives: Salesforce

Add Email Signature in Salesforce

Salesforce Classic View Enhanced Setup Menu:

  • Click the drop down next to your name.
  • Under “My Settings,”click Email | then click My Email Settings.
  • Add your signature to the “Email Signature” field.
  • Click Save.

Salesforce Classic view Non-Enhanced Setup Menu:

  • Click Setup.
  • Click Personal Setup.
  • Click Email | then click My Email Settings.
  • Enter your signature into the email signature field.
  • Click Save.

Salesforce Lightning Experience:

  • Click your profile icon | then click Settings.
  • Click Email | click My Email Settings.
  • Enter your signature into the “Email Signature” field.
  • Click Save.

Note: Signatures will be added to all personal emails and emails that use text templates. Signatures won’t be added to emails that use HTML templates, as signatures need to be part of the template.

Display pageBlock Buttons in bottom

We use location attribute in pageBlockButtons to display pageblock button in bottom alone. The possible values of location attribute are “top”, “bottom” and “both”. If not specified, this value defaults to “both”.

Here I’m using location="bottom" to display buttons in bottom only.

<apex:page standardController="Account">
	<apex:form>
		<apex:pageBlock mode="edit">
			<apex:pageBlockButtons location="bottom">
				<apex:commandButton action="{!Save}" value="Save"/>
				<apex:commandButton action="{!Cancel}" value="Cancel" immediate="true" />
			</apex:pageBlockButtons>
			<apex:pageBlockSection columns="2" title="Account Information">
				<apex:inputField value="{!Account.Name}"  required="true"/>
				<apex:inputField value="{!Account.Phone}"/>
			</apex:pageBlockSection>
		</apex:pageBlock>
	</apex:form>
</apex:page>

Note: If a pageBlock header facet is defined, the facet overrides the buttons that would normally appear at the top of the page block. Likewise if a pageBlock footer facet is defined, the facet overrides the buttons that would normally appear at the bottom of the page block.

Call Multiple Apex Methods in Lightning Controller

Apex Controller:

public with sharing class AccountController {

    @AuraEnabled
    public static Account getAccount(Id accountId) {
        Account acc = new Account();
        acc = [SELECT Id, Name, Description FROM Account WHERE Id=:accountId];
        return acc;
    }
    
    @AuraEnabled
    public static List<Attachment> getAttachments(Id parentId) {                            
        List<Attachment> listAttachment = new List<Attachment>();
        listAttachment = [SELECT Id, Name FROM Attachment WHERE ParentId = :parentId];
        return listAttachment;
    }
}

Lightning Component:

<aura:component controller="AccountController" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="acc" type="Account"/>
    <aura:attribute name="attachments" type="Attachment[]"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <div>
        <div>{!v.acc.Name}</div>
        <div>{!v.acc.Description}</div>
        
        <ul>
            <aura:iteration items="{!v.attachments}" var="a">
                <li>
                    <a target="_blank" href="{! '/servlet/servlet.FileDownload?file=' + a.Id }">{!a.Name}</a>
                </li>
            </aura:iteration>
        </ul>
    </div>

Lightning Controller:

({
    doInit : function (component) {
    var action = component.get('c.getAccount');
    action.setParams({
        "accountId": component.get("v.recordId")
    });
        
	action.setCallback(this, function(response) {
        var state = response.getState();
        if (state == "SUCCESS") {
            var account = response.getReturnValue();
            component.set("v.acc", account);
        }
    });
        
    var action2 = component.get('c.getAttachments');
    action2.setParams({
        "parentId": component.get("v.recordId")
    });
        
	action2.setCallback(this, function(response) {
        var state = response.getState();
        if (state == "SUCCESS") {
            var attachments = response.getReturnValue();
            component.set("v.attachments", attachments);
        }
    });
    $A.enqueueAction(action);
    $A.enqueueAction(action2);
}
})

Enum in Apex

Biswajeet   October 20, 2017   No Comments on Enum in Apex

An enum is an abstract data type with values that each take on exactly one of a finite set of identifiers that you specify. Enums are typically used to define a set of possible values.

Although each value corresponds to a distinct integer value, the enum hides this implementation so that you don’t inadvertently misuse the values, such as using them to perform arithmetic. After you create an enum, variables, method arguments, and return types can be declared of that type. Apex provides built-in enums, such as LoggingLevel, and you can define your own enum.

To define an enum, use the enum keyword in your declaration and use curly braces to demarcate the list of possible values.

For Example:
The following code creates an enum called Season:

public enum Season {WINTER, SPRING, SUMMER, FALL}

By creating the enum Season, you have also created a new data type called Season. You can use this new data type as you might any other data type.

For Example:

Season e = Season.WINTER;

Season CheckSeason(Season e) {
    if (e == Season.SUMMER){
		return e;
	}
} 

Enum Methods:
All Apex enums, whether user-defined enums or built-in enums, have the following common method that takes no arguments.

values : This method returns the values of the Enum as a list of the same Enum type. Each Enum value has the following methods that take no arguments.
name : Returns the name of the Enum item as a String.
ordinal : Returns the position of the item, as an Integer, in the list of Enum values starting with zero.
Note: Enum values cannot have user-defined methods added to them.
For Example:

Integer i = StatusCode.DELETE_FAILED.ordinal();
String s = StatusCode.DELETE_FAILED.name();
List<StatusCode> values = StatusCode.values();

SOQL Statement to Select All Records Even From Recycle Bin

SOQL statements can use the ALL ROWS keywords to query all records in an organization, including deleted records and archived activities.

For Example:

[SELECT COUNT() FROM Contact WHERE AccountId = '0030E00000D34jq' ALL ROWS]

You can use ALL ROWS to query records in your organization’s Recycle Bin. You cannot use the ALL ROWS keywords with the FOR UPDATE keywords.