How to deploy sharing rules using Apache ANT tool in Salesforce?

Sample package.xml:
   
 <types>
        <members>Account.*</members>
        <name>SharingCriteriaRule</name>
    </types>
    <types>
        <members>Account.*</members>
        <name>SharingOwnerRule</name>
    </types>

Cheers!!!

force:createRecord example in Salesforce Lightning

Sample Code:

CreateAccountComponent.cmp

<aura:component implements="flexipage:availableForAllPageTypes">
    <lightning:button label="Create Account" variant="brand" onclick="{!c.createAccount}"/>
</aura:component>

CreateAccountComponentcontroller.js

({
createAccount: function (component) {
        var createRecordEvent = $A.get('e.force:createRecord');
        if ( createRecordEvent ) {
            createRecordEvent.setParams({
                'entityApiName': 'Account',
                'defaultFieldValues': {
                    'Type' : 'Prospect',
                    'Industry' : 'Apparel',
                    'Rating' : 'Hot'
                }
            });
            createRecordEvent.fire();
        } else {
            /* Create Record Event is not supported */
            alert("Account creation not supported");
        }
    }
})

Add the lightning component to any page. I have added it to the Account detail page.

Output:



Cheers!!!

How to query all non portal user roles in Salesforce?

SOQL:

SELECT Id, Name FROM UserRole WHERE PortalType = 'None'

Output:


Cheers!!!

lightning:layout in Salesforce

Represents a responsive grid system for arranging containers on a page. A lightning:layout is a flexible grid system for arranging containers within a page or inside another container. The default layout is mobile-first and can be easily configured to work on different devices.

Sample Code:

<aura:component implements="flexipage:availableForAllPageTypes" >
    <div class="c-container">
        <lightning:layout horizontalAlign="center">
            <lightning:layoutItem flexibility="auto" padding="around-small">
                <ui:inputSelect multiple="false">
                    <ui:inputSelectOption label="All Types" text="" value="true"/>
                </ui:inputSelect>
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="auto" padding="around-small">
                <button class="slds-button slds-button_brand">Search</button>
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="auto" padding="around-small">
    <ui:button label="New"/>
            </lightning:layoutItem>
        </lightning:layout>
    </div>    

</aura:component>

Output:


Cheers!!!

How to set default value in picklist in Lightning Component in Salesforce?

Lightning Component:

<aura:component access="global">
    <ui:inputSelect aura:Id="makeId" multiple="false" label="Select Make">
        <ui:inputSelectOption label="Acura" text="acura" value="true"/>
        <ui:inputSelectOption label="Audi" text="Audi"/>
        <ui:inputSelectOption label="BMW" text="bmw"/>
        <ui:inputSelectOption label="Honda" text="honda"/>
        <ui:inputSelectOption label="Hyundai" text="hyundai"/>
        <ui:inputSelectOption label="Mercedes Benz" text="merc"/>
        <ui:inputSelectOption label="Nissan" text="nissan"/>
    </ui:inputSelect><br/><br/>
    <ui:button label="Find Vehicles" press="{!c.findVehicles}"/>
</aura:component>

here value="true" is used to set the default value.

Lightning Component Controller:

({
findVehicles : function(component, event, helper) {
        alert(component.find("makeId").get("v.value"));
}
})

Output:


When Find Vehicles button is clicked, selected value will be alerted on the screen.

Cheers!!!