Configure Force.com Migration Tool for deployment Apache ANT

Force.com Migration Tool

Prerequisites for Using the Force.com Migration Tool

Before you can use the Force.com Migration Tool, Java and Ant must be installed and configured correctly. If you already have Java and Ant on your computer, you don’t need to install them, so first verify the installation from a command prompt.

 

Step 1 – Download and Install Java – Many of you have already installed the JDK in your system if not then you can download JDK from Here.

Download Java
Step 2 – Download Apache Ant – Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. You can Download Apache Ant From Here

Download ANT.png
Step 3 – Set the path for ANT_HOME and JAVA_HOME :- After you have downloaded the Java and Apache Ant and JDK then place the Apache Ant into C drive for convenience.Now, let us set the path for both Java and Ant. Go to

  • Control Panel -> System and Security -> System -> Advance System Settings ->
  • a Popup will open Click Environment Variables – >

ANT_HOME.png

  • Click New under user variable and enter “ANT_HOME” for variable name and use ant location for variable value for example if you have pasted the ant into c drive then it will look like “C:\ant” click OK.

ANT_PATH.png

  • Again Click New under user variable and enter “JAVA_HOME” for variable name, use jdk location for variable value for example – “C:\Program Files\Java\jdk1.8.0_51”

JAVA_HOME.png
Step 4 – Set the PATH:- Now, we have added the path for Ant and Java. We need to add one more variable name PATH. Click New under user variable and enter “PATH” for variable name, use “%ANT_HOME%\bin;%JAVA_HOME%\bin;” for variable value.

PAHT_HOME.png
Now, time to do some testing for the above steps that we have setup until now. Open command prompt and type java -version hit enter, again type javac -version and hit enter. Now, type ant -version and hit enter you see the message like in below image.

Note: – If you receive Tools.jar not found error, go to “/Ant/manual/api/org/apache/tools/ant/util/JavaEnvUtils.html” and replace “java.home” with “java_home”.

CMD.png

Step 5 – Download Force.com Migration Tool: – In this step you need to download the force.com migration tool and can be downloaded from “Here“. After download unzip the file using 7Zip winrar or any other tool. You will see find a .jar file a html file and a folder name sample.

Salesforce ANT
Step 6 – Copy “ant-salesforce.jar” file from the file that you downloaded into step 5 (folder name “salesforce_ant_41.0”) and paste it to ant lib folder

Ant _ Salesforce

Download the required files from “Here” for the demo purpose.

Step 7 – After you downloaded the file from the above link place the file into your suitable location and unzip the file. Now, open build.properties file into any text editor and provide the credentials for the source and target Org then save as using properties extension of the file.

Step 8 – Open command prompt if you have closed this other wise use the same. Navigate to the directory where you have located this folder and then go to deploymentFolder folder.

Directory.png
Step 9 – It’s time to retrieve the data from the test Org type ant retrieve and hit enter

Retrieve.png

File Location

Step10 – Deploy the retrieved components into the Production Org. Type ant deploy

Deploy.png

If you have any problem then come up in the comment section with.

Hurray you have setup the ANT with Salesforce for Deployment.

Happy Learning 🙂 😉

Advertisements

Salesforce Lightning Interview QA

I have compiled some Interview Questions related to Salesforce Lightning that are given below:

1 – One User is viewing a Lightning Component in which some fields are being displayed and in the mean time some other user have changed the value of the field. How do you ensure that user will see the updated value?

Answer – Using platform event. Streaming API will not work into the Lightning Environment.

2 – What is Lightning Data Service(LDS) ? What are the benefits of using LDS?

Answer – LDS is a standard controller for Lightning Component. Using Lightning Data Service we can Create, Retrieve, Delete and update records for which we do not need to write the apex class. Lightning Data Services ensures the FLS by itself. For more info see Here.

3 – When we can not use LDS in Lightning Component?

Answer – LDS is used for single record so when we are dealing with Bulk records then we can not use LDS.

4 – What is main difference between Lightning Component and Visual Force Pages OR Why we should go for Lightning Component?

Answer – Visualforce components are page-centric and most of the work is done on the server. Lightning is designed from the component up, rather than having the concept of a page as its fundamental unit. Lightning Components are client-side centric, which makes them more dynamic and mobile friendly.

5 – Will Lightning Components be replacing Visualforce?

Answer – No.

6 – Is Lightning an MVC framework ?

Answer – No, it’s component based framework.

7 – What aura:method does in Lightning Component?

Answer – We can Use aura:method to define a method as part of a component’s API. This enables us to directly call a method in a component’s client-side controller instead of firing and handling a component event

8 – How many Components can be used in a single lightning application?

Answer – There is no Limit.

9 – Will Visual Force page will stop working on Lightning UI?

Answer – No, VF page will work in the Lightning UI as Classic UI.

10 – Can we include external Library into Lightning Component?

Answer – Yes, we can include multiple library into Lightning component.

More QA updates soon 🙂

Salesforce – Quickbooks Online Integration – oAuth 2.O

Hi All, Hope you all enjoyed my previous Integration related posts. I have come up with another integration. In this post we will make connection between Salesforce and Quickbook System using Apex, VF page.

Earlier Quickbooks uses oAuth 1.0 for the authentication but now it has updated it’s API and using oAuth 2.0 so in this Integration we are going to use oAuth 2.0

Step1 – Create a Custom Object OR Custom Metadata to store the information about Access and Refresh Token. If you are thinking about to use Custom Setting the answer is No because Access Token length is more than 255 Character and in Custom Setting we can store data upto 255 Character.

Setup -> Create -> Objects -> New -> Your Object will look like below image

QuickBooks Infos Object

Step2 – Create a Trail Account of QuickBooks From Here.

Step3 – Create a connected App into QuickBooks Developer account, Follow the steps given into this Link. Please enter a redirect URI. for example if you want to redirect into “QuickbookConnection” VF page and your org base URL is “https://dreamhouse-a-dev-ed.my.salesforce.com” then your Redirect URI will be as given below

https://dreamhouse-a-dev-ed–c.ap5.visual.force.com/apex/QuickbookConnection

Step4 – Now, in this Step get the Consumer Secret and Consumer Key and to get the key follow the steps given in This Link.

Connected App

Step5 – Now, Create a Apex Class. File -> New -> Apex Class -> Name it “QuickbookConnection” -> OK. Use below code the class

Step5 – Create a VF page. File -> New -> Visualforce Page -> Name “QuickbookConnection” -> OK. and use below code for this page


<apex:page controller="QuickbookConnection">
<apex:slds />
<apex:form id="theForm" >
<apex:pageblock >
<apex:pageMessages ></apex:pageMessages>
<apex:actionstatus id="statusAuthQuickBooks">
<apex:facet name="start">
<div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb; height:100%;opacity:0.65;width:100%;">
<div class="waitingHolder" style="top: 100px; width: 91px;">
<img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
<span class="waitingDescription">Loading...</span></div>
</div>
</apex:facet>
</apex:actionstatus>
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!doAuthorizationQuickBooks}" value="Authorize with Quickbooks" />
<apex:commandButton action="{!doFetchAccessToken}" value="Complete Authorzation" status="statusAuthQuickBooks"
reRender="theForm" />
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:page>

tada we have done with the coding and configuration part, now time to test the functionality. Click preview on the VF page. Click on Authorize with QuickBooks it will take you to login page of QuickBooks login with your username and password.

If you have more than 1 Sandbox it will list all the sandbox over there select one which you want to integrate.

Authorize the Application and you will be redirected to the same page now click on Complete Authorization it will create a record for the custom Object that you have created with success message

See the working in below gif Image

Salesforce - Quickbooks Working.gif

Now, We have access token we can make the callout to get the data from QuickBooks into Salesforce. You can find the complete code form Here.

If you have any problem then please come up into comment section.

Happy Learning 🙂 😉

Resources –

It’s the time to pick, Salesforce MVP 2018!

Salesforce nomination are back for year 2018 nominate your favourite MVP

Just improvise your learning in Salesforce !!

Salesforce MVP nominations are now Open!! It’s the time to learn about MVP program and nominate the Salesforce Trailblazer Community members who have been a real community supporter and have helped you the most in 2017!!.

What does Salesforce MVP Do?

According to Salesforce, Salesforce MVPs (Most Valuable Person) help millions of customers thrive by sharing their knowledge, leadership, and creativity within the Trailblazer Community. Salesforce MVP status is awarded for a one-year period. Each following year, MVP status is reviewed and extended based on their current contributions. New MVP classes will be welcomed once per year, and anyone can nominate an MVP during the once-yearly nomination period.

MVP Characteristics?

  • Expertise: An individual who maintains a strong and updated understanding of Salesforce Ohana and its latest products.
  • Generosity : Always active and open to help others succeed in the Salesforce Ohana/ecosystem.
  • Leadership: Consistently seeks opportunities to innovate and…

View original post 81 more words

URLFOR Function Explained – Salesforce

URLFOR Returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page.
This can be used to return a reference to a file contained in a static resource archive (such as a .zip or .jar file). Below is the Syntax Overview of URL for function

{!URLFOR(target, [id], [inputs], [no override])} 

Below is the description of all the attributes in detail:

Target: Action, or any static resource for image or Javascript.

Id : Name that is Of String or record ID (depends on the “target”).

parameters: Additional parameters passed. Format: [parameters1=”value1″, parameters2=”value2″, parameters3 = value3]

no override: A Boolean flag. Set to true if to display a standard Salesforce page     regardless of whether you have defined an override for it (default false)  [nooverride=1] OR [nooverride=0] OR [nooverride=true] OR [nooverride=false]

The input values can be dynamic. For example, to include an account ID, specify:
{!URLFOR($Page.myVisualforcePage, null, [accountId=Account.Id])}

Edit – URLFOR($Action.Account.Edit, Account.Id, [nooverride=1])

View – URLFOR($Action.Account.View, Account.Id)

New  – URLFOR($Action.Account.New)

Delete – URLFOR($Action.Account.Delete, Account.Id)

List View – URLFOR($Action.Account.Tab,$ObjectType.Account)

Image – <apex:image url=”{!URLFOR($Resource.redflag)}” height=”50″ width=”50″ />

Note: – Some Object may have different OR more action for those Object you can find using.

Standard Object 

Setup -> Customize -> Object Name -> Button Links and Action 

Custom Object

Setup -> Create -> Objects -> Find Your Object -> Button Links and Actions

In General You can use the below Syntax $Action.sObjectType.Name

$Action – Defined the action

sObjectType – API name of the Salesforce Object

Name – Name of the Action that may be Edit, New, Edit and Delete, etc..

URLFor

Here is a sample VF page for account Object, to see preview of the VF page append record Id of account Object into the URL like below in Red Color

https://dreamhouse-a-dev-ed–c.ap5.visual.force.com/apex/URLFOR?id=0017F0000099bEk

Happy Learning 🙂 😉

Call Child Component Controller From Parent Component – Aura Method

In my previous posts we have seen how we can use application and component events and when we should go for. You all must be thinking what if we want to call the controller of child component controller from the parent component. So, in this post we will see how we can do the above things.

aura:method: – Use <aura:method> to define a method as part of a component’s API. This enables you to directly call a method in a component’s client-side controller instead of firing and handling a component event.

The <aura:method> tag has these system pre defined attributes that we can use

Name: – The method name. Use the method name to call the method in JavaScript code.

Action: – The client-side controller action to execute

Access: – he access control for the method. Valid values are: public and global

Description: – The description of method.

Declaring Parameters: – We can also use parameters to send the values from parent to child using the attributes.

Below is sample of child Component

““

<aura:method name=”sampleMethod” action=”{!c.doAction}”
                        description=”Sample method with parameters”>
       <aura:attribute name=”param1″ type=”String” default=”parameter 1″/>
       <aura:attribute name=”param2″ type=”String” />
</aura:method>

““

Define the action that needs to be executed when “sampleMethod” gets called from the parent component. Create a method into Controller of Child Component. Child Component Controller sample code.

““

({
doAction : function(cmp, event) {
var params = event.getParam(‘arguments’);
if (params) {
var param1 = params.param1;
// add your code here
}
}
})

““

Get the value into the child controller: – Retrieve the arguments using event.getParam(‘arguments’). It returns an object if there are arguments or an empty array if there are no arguments. For example if you are passing 2 parameters then you can get like below

Step1: – Get the array of all the arguments

var params = event.getParam(‘arguments’);

Step2: – Now, get the value of the attribute using the name of the attribute.

var param1 = params.param1;

var param2 = params.param2;

In Final Step Call the method from the Parent Code: –

Step1: – Call the child component inside the parent component using the syntax like below and use aura:id for the child component which will let you find the child component and then you can call the controller method.

<c:childComponent aura:id=’childCmp’ /> – Use this Syntax if no namespace is defined by you.

<yourNameSpace:childComponent aura:id=’childCmp’ /> Use this Syntax if you have your own       namespace is defined by you.

Step2: – Create a button OR any event in which you want to execute the child controller method.

<lightning:button variant=”brand” label=”Submit” onclick=”{! c.handleClick }” />

Step3 : – Call the child controller method from the parent controller method.

({

handleClick : function(component, event, helper){

// Find the child component using the aura:id that we have given while creating the parent component and store the same into a variable.

var childCmp = component.find(‘childCmp’);

// Call the Child Controller method using childCmp variable dot method name defined into the child component

childCmp.sampleMethod(‘Sample Value for Param 1’, ‘Sample Value For Param 2’); // Pass the parameters here

}

})

Example: – For an example we will take a very simple scenario for creating quick contact for the selected account doing this we will reduce the work of going to account detail page and then create a contact from there. You can get the complete code from Here.

Component will look like below.

Aura Method.gif

 

Happy Coding 🙂

If you have any questions let me know in comments Section.

Resource: –

Salesforce Document

Top 10 Features for Lightning Development – Spring 18 Release

New Lightning Components

Note: – The following components are new and require API version 42.0 and later.

  • lightning:carousel (Beta): – A collection of images that are displayed horizontally one at a time. As this is a beta version feature it will have some limitations.

base_carousel

  • lightning:formattedAddress: – Displays a formatted address that provides a link to the given location on Google Maps.

base_formattedAddress

  • lightning:inputAddress: – Input fields represents an address compound field with support for street, city, province, postal code, and country.

base_inputAddress.png

  • lightning:inputField : – An editable field with a label, help text, and value that corresponds to a field on a Salesforce object. This component must be nested in a lightning:recordEditForm component.
  • lightning:inputName: – Represents a name compound field with support for salutation, first name, middle name, last name, informal name, and suffix.

base_inputName.png

  • lightning:listView : – Represents a list view of records that you own or have read or write access to, and records shared with you.

base_listView.png

  • lightning:recordEditForm : – A record edit or record create layout that displays one or more fields provided by lightning:inputField.

base_inputField.png

  • lightningsnapin:prechatAPI : – Enables customization of the user interface for the pre-chat page in Snap-ins Chat.

Changed Lightning Components

lightning:datatable: – Datatable an amazing feature that we got in the previous release (winter 18) has many new features in the coming release Spring 18.

Text wrapping and clipping within a column is now supported. Text wrapping expands the height of the rows to reveal more content. Content is clipped by default if the number of characters is more than what the column width can hold. To toggle between the two views, select Wrap text or Clip text from the dropdown menu on the column header.Other features that are now supported include:

  • Appending icons to the header column
  • Header-level actions
  • Infinite loading of rows
  • Row-level actions
  • Selecting rows programmatically
  • Using a button as a data type

These features are captured by the following lists of attributes, column properties, and data types.

The following attributes are new.

  • enableInfiniteLoading—Enables or disables infinite loading. The default is false.
  • isLoading—Specifies whether more data is being loaded, and displays a spinner if there is. The default is false.
  • loadMoreOffset—Determines when to trigger infinite loading based on how many pixels the table’s scroll position is from the bottom of the table. The default is 20.
  • selectedRows—Enables programmatic row selection with a list of keyField values.
  • maxRowSelection—Maximum number of rows that can be selected. Checkboxes are used for selection by default, and radio buttons are used when maxRowSelection is 1.
  • onheaderaction—The action triggered when a header action is clicked. By default, it also closes the header actions menu.
  • onloadmore—The action triggered when infinite loading loads more data.
  • onresize—The action triggered when the table renders columns each time it resizes a column.
  • onrowaction—The action triggered when a row action is clicked. By default, it also closes the row actions menu.
  • rowNumberOffset—Determines where to start counting the row number. The default is 0.
  • showRowNumberColumn—Shows or hides the row number column. Set to true to show the row number column. The default is false.

The following column properties are new.

  • actions—Appends a dropdown menu of actions to a column.
  • cellAttributes—Provides additional customization, such as appending an icon to the output. You can pass in these attributes: iconName, iconLabel, iconPosition.
  • iconName—The Lightning Design System name of the icon. Names are written in the format standard:opportunity. The icon is appended to the left of the header label.

The following data types are now supported.

  • action—Displays a dropdown menu using lightning:buttonMenu with actions as menu items. This data type supports these typeAttributes properties: rowActions and menuAlignment.
  • button—Displays a button using lightning:button. This data type supports these typeAttributes properties: disabled, iconName, iconPosition, label, name, title, variant.

The url data type now supports the following typeAttributes property.

  • label—The text to display in the link. Give label of the record name or anything you want.

The date type now supports the following typeAttributes properties.

  • day—Valid values are numeric and 2-digit.
  • era—Valid values are narrow, short, and long.
  • hour—Valid values are numeric and 2-digit.
  • hour12—Determines whether the time is displayed as 12-hour. If false, time displays as 24-hour. The default setting is determined by the user’s locale.
  • minute—Valid values are numeric and 2-digit.
  • month—Valid values are 2-digit, narrow, short, and long.
  • second—Valid values are numeric and 2-digit.
  • timeZone—The time zone to use. Implementations can include any time zone listed in the IANA time zone database. The default is the runtime’s default time zone. Use this attribute only if you want to override the default time zone.
  • timeZoneName—Valid values are short and long. For example, the Pacific time zone displays as PST if you use short or Pacific Standard Time if you use long.
  • weekday—Valid values are narrow, short, and long.
  • year—Valid values are numeric and 2-digit.

 

Happy Reading 🙂

You can try all these features into the Sandbox Org once this release has been loaded into Sandbox after 5th Jan OR 6th of Jan 2018.

Resources: –

Salesforce Release Document

 

Introduction to Salesforce Quip!

Amazing blog with great content

Just improvise your learning in Salesforce !!

Quip is a smarter cloud-based productivity and collaboration platform tool where you can create, document, discuss, and organise the stuffs that your team works on. People keep on emailing documents back and forth to get feedback, but now with Quip everyone can look at everyone else’s updates to a document, in real time as they occur. Moreover, Quip documents are cloud-based, easy to access from multiple devices, and it provides awesome features for your team to edit the docs live. Quip is accessible from web browser, Quips desktop app and Quips mobile app, so you can stay connected.Thus, being more productive, more focused and happier than you were before.

Quip allow you to create groups where you can work upon in collaboration whether it can be Friends, Family, Team at work, classmates and others. 

What makes Quip different from other collaboration tools?

You might be thinking, what are the key factors…

View original post 408 more words

Spring 18 Release Features

There are many exciting features coming into the next release of Salesforce which is Spring 18 and that are listed below and Spring 18 is available into Pre Release org.

Sales Cloud Features

  • Increase your productivity by changing the order of the Tabs into Sales app with quick steps.

Sales App.png

  • Increase Your Efficiency by Managing List Emails in One Place.

List Emails.png

List Email

  • Generate the Leads directly from the LinkedIn
  • Add Products into Opportunity in a fast and efficient way, Leads and Contacts into Campaigns. 

Add Product

Sales Cloud Features :

  • Give Live Agent Users Access to Knowledge
  • Insert Article Content into Case Emails

No cutting. No pasting. No retyping. Agents can insert article content directly into case emails, quickly answering customer questions. This change applies to Lightning Experience.

  • Reply and Forward Email
  • Chat Faster with Quick Text in Lightning Experience

live_agent_quick_text_in_lightning

Quick Text.png

  • Chat Smarter with Lightning Knowledge

live_agent_knowledge_component.png

  • Entitlement Management: View Work Order Milestones in Lightning Experience
  • Get Customer feedback using Survey Object.
  • Override the standard actions based on the environment

Override Actions

  • Use Validation Rule Formulas with Custom Metadata Types
    • Create a custom metadata type. In this example, we named it DiscountLimits.
    • Create a custom field for your type. We named it maxDiscount.
    • Create a record. We named it FoodDiscount.

When done, you can reference the custom metadata type in your validation rule. The syntax is:

$CustomMetadata.CustomMetadataTypeAPIName.RecordAPIName.FieldAPIName

Your validation rule will look like some thing below

Discount > $CustomMetadata.DiscountLimits__mdt.FoodDiscount.maxDiscount__c

Custom Permission for Validation Rule

Custom Permissions: –

Use custom permissions to give users access to custom processes or apps.  Custom permissions let you define access checks that can be assigned to users via permission sets or profiles, similar to how you assign user permissions and other access settings.
You can query custom permissions in these ways.
  • To determine which users have access to a specific custom permission, use Salesforce Object Query Language (SOQL) with the SetupEntityAccess and CustomPermission sObjects.
  • To determine what custom permissions users have when they authenticate in a connected app, reference the user’s Identity URL, which Salesforce provides along with the access token for the connected app.

 

Scenario and Different ways to achieve it: – None user can Edit the Opportunity once opportunity is on Closed Won Stage, Only Certain Set of Users can Edit the Opportunity.

Problem: – We have instruction that we can not alter the profile, permission set and we can not write the code as well.

Solution: – We will see three solution here that will work for us and their pros and cons, So that we can choose the right solution for our problem.

Solution #1 :- Write a validation rule on the Opportunity Object and put the hardcode user Ids there in validation rule. For example

AND(
ISCHANGED(STAGENAME),
$Profile.Name <> ‘System Administrator’,
PRIORVALUE(TEXT(STAGENAME)) = ‘Closed Won’,
$User.Id = ’15Digit UserIdhere’,
$User.Id = ‘anoother user Id here’,
.
.
.
.
and So on
)
the above validation rule will work like a champ but it has some cons as well

** UserId = 15 characters, not 18 characters

Cons: Difficult to maintain, admin need to update each validation rules (if many) affected for maintenance or any change in username or user.

Solution #2: – Custom Setting: – We can use hierarchical custom setting  in validation rule. Create a custom setting and store the user ids into Custom Setting.

Setup -> Develop -> Custom Settings -> New ->

Click Manage and then New to Create New record for Custom Setting

Use Validation Rule like below

AND(
         $Profile.Name <> ‘System Administrator’,
          NOT CONTAINS($Setup.SpecialPermission__c.User_Ids__c ,$User.Id),
          ISCHANGED(STAGENAME),
          TEXT(PRIORVALUE(STAGENAME)) = ‘Closed Won’
)

** UserId = 15 or 18 characters is fine, because we are using CONTAINS()

Pros: –

  • One place to manage all users
  • Can be used in multiple validation rules

Cons: –

  • Admin need to update the values again and again if user is leaving or joining
  • Only 14 OR 15 User Ids can be stored because the Max length of TextArea field is 255
  • We can use User Ids only

Solution #3 – Custom Permissions: – We can use custom permission to achieve our requirement.

Create new Custom Permission: –

1 – Setup -> Develop -> Custom Permissions -> New ->

Custom Permission

2 – Now, next step is to create a new permission set and assign the above custom permission to that permission set.

Setup -> Manage Users -> Permission Sets -> New

Permission Set.png

Save. Click on Custom Permission Link to Add the Custom Permission into the Permission Set. Click Edit and Select the available custom permission then save it.

Assign this permission set to the users whom you want to give the access for Editing the Opportunity.

Then Replace the above validation rule with the below formula

AND(
         $Profile.Name <> ‘System Administrator’,
         NOT( $Permission.Special_User_Edit ),
         ISCHANGED(STAGENAME) ,
        TEXT(PRIORVALUE(STAGENAME)) = ‘Closed Won’
)

Pros:-

  • We can control and manage the users with Permission Set
  • We can use N no of user and assign this permission to the appropriate users
  • We do not need to make the changes again and again into validation rule

Cons: –

  • No cons found yet.

Resources : –

Salesforce Document

Salesforce Article