Create Remote Site Setting through Visualforce Page

Hey Salesforce Ohana, I am back with new blog post. In this blog I will explain How to create a Remote Site Setting through coding.

Most of developer or admin usually create Remote Site Setting through Remote Sites Section [Administer -> Security Control -> Remote Site Settings] in your Salesforce organization.

If you do not know what is Remote Site Setting?

Why we use Remote site setting?

You can refer this blog post for complete details.

Now it’s time for coding.


Before starting , you should know about MetaData API .

A Secrete key to access, create your Metadata like Workflows, Remote Site, Validation Rules.

Let’s download MetaData WSDL File [Build -> API -> MetaData WSDL] and generate apex class using this WSDL File [Build -> Develop -> Apex Classes -> Generate from WSDL] or you can refer this MetadataService apex class.


Add your Salesforce Organization domain name and your visualforce page domain name in Remote site setting by following steps.

[Administer -> Security Control -> Remote Site Settings]

Now, Create a Visualforce Page for input Remote site details and apex controller for business logic.

Below is your apex controller code which will call MetaDataPort Method in the MetaDataService apex class for generating of session Id your salesforce organization and enter remote site details and call createMetaData() method.


You can refer the complete code here.

Hope you find this helpful, in case of any queries/concerns, please post a reply or drop an email to me at .

Happy Coding 🙂





Salesforce DX – Salesforce Developer Experience

Salesforce Developer Experience which is the most Trending Topic in these days.

SFDX is a new tool to manage and develop apps on the platform. It is created for developers to build apps on together in a team.

It makes the developers experience easy so that developers can do coding with less effort in a short period of time and build apps together with version control system.

It also changed the way to deploy the application on platform.

Some Import features of Salesforce DX

  • Scratch Org
  • Source Sync
  • Salesforce Command Line Interface(CLI)
  • Test Runner
  • Continuous Integration
  • Force IDE and Visual Studio with DX Support

Let’s start some work on SFDX tool

Download SFDX CLI and install in your System.

Enable DEV HUB in your org so you can create scratch orgs from CLI and use this tool easily or you can create a 30 days trail org in which DEV HUB is by default activated.

Open your Command window and authorize your org

sfdx force:auth:web:login

it will redirect to salesforce login page automatically and then enter your DEV HUB org username and password.

After login you will get something like this.


Check your connected orgs.

sfdx force:org:list


I have worked on these three org that’s why it’s showing these three orgs list but you will get only one org DevHub if you are using it first time.

You can check the all available things which you can do using SFDX CLI and commands list with explanation by using below two commands

Sfdx force –help

Sfdx force:doc:commands:list

This slideshow requires JavaScript.

Let’s create a SFDX Project

sfdx force:project:create -n ProjectName


Your Project contains these files and folders.


sfdx-project.json is the project configuration file contains the sfdx project information and it also tell the sfdx where to put all components when you pull data from scratch org.


project-scratch-def.json is the scratch org definition file indicates which type of scratch org will be created and some basic details for scratch org like orgName or edition of Scratch org.

You can manually edit this file like replace Developer edition to Enterprise if you want to create Enterprise Edition scratch org or any other edition.


Force-app folder contains all components like apex class, custom objects, visualforce pages etc..

Create a Scratch Org

sfdx force:org:create -s -f config/project-scratch-def.json -a AliasName

-s indicates this scratch org would be the default scratch org for this project.

-f indicates the path of scratch org definition file

-a indicates the alias name for this scratch org

Alias Name will be helpful when you have multiple scratch orgs. You just need to put alias name for open scratch org instead of using the username of scratch org.


Open Scratch org

sfdx force:org:open

This will open the default scratch org if you have otherwise you can use alias name to open other scratch org.

sfdx force:org:open –u AliasName


Create a Apex class in your project

sfdx force:apex:class:create -n ApexclassName -d force-app/main/default/classes

-n indicates the Apex class Name

-d indicates the Path for Apex class in your project


Open Apex class in your project and do some thing and push all changes to scratch org


Push all changes to Scratch org

sfdx force:source:push


Let’s review it in the scratch org

Login in to the scratch org by sfdx force:org:open using SFDX it will automatically open your scratch org or you can get list of orgs to know the details of all connected orgs and scratch orgs.


Let’s do some change in the apex class from Scratch org and pull changes you your project.

This Is the way you can sync all changes with your project to scratch orgs.

sfdx force:source:pull




You can refer some related blog posts or official site for more details-

Hope you find this helpful, in case of any queries/concerns, please post a reply or drop an email to me at .



How to Tackle View State Issue During Upload file as a Attachment through Visualforce Page – Part 2


Hello guys , I am Back with my new Blog Post . In this Post You will Learn Two things .

  • Upload file as a Attachment  Without Apex Controller
  • What is Salesforce Ajax toolkit and How you can use Ajax Toolkit for Upload File

Please Refer my Previous Blog Posts to get to know Upload file through visualforce and Tackle View State Issue through apex Controller

First of all Do you Know about Salesforce Ajax Toolkit ???q-590x446

If you don’t know then do not worry just take long breath and read this artical.

Let’s come to the Point and discuss What is Salesforce Ajax Toolkit ?????

Ajax Toolkit is like a Javascript Wrapper which you can use in Your Visualforce Page to Interact with Salesforce Standard and custom Objects .

You can query Salesforce Objects Data , Create records and attachments without using Apex with your Visualforce Page.

Now the Questions arise When to use ajax toolkit??

Best situation to work with ajax toolkit is when you have to work with small amount of data.

AJAX works best with  small amounts of data (up to 200 records, approximately six fields with 50 characters of data each).

You have to follow three steps for working with ajax toolkit in your visualforce Page.

  • Connecting to the API – Include Connection.js file that is ajax toolkit Javascript file in your Visualforce Page and Get the Sforce Session using sforce.connection.sessionId='{!GETSESSIONID()}’

    After execution of Connection.js script , the toolkit is loaded and a global object, sforce.connection, is created. This object contains all of the API calls and AJAX Toolkit methods, and manages the session ID.

  • Embed API Calls in Javascript – Write Javascript code for Making Instance of  Sforce Object like “new sforce.SObject(“Attachment”)” and create attachment using sforce.connection.create([attachment] .
  • Processing result – Process the Result on creation of attachment and show success or failure message .onSuccess : function(result, source) {

    if(result[0].getBoolean(“success”)) {

    // do your code whatever you want to show on success



    onFailure : function(error, source) {

    // do your code on failure


You can go through the Salesforce Ajax Toolkit Developer Docs for more reference .

Here is the Look of your Visualforce page .

When you Load the Page .


When you Clicked Upload Button Without Record ID in URL .


When you Clicked Upload Button Without Selecting File for upload.


When you selected file and clicked Upload Button .


Here is the Visualforce Page Code With Ajax Toolkit.

Hope you find this helpful, in case of any queries/concerns, please post a reply or drop an email to me at .

Salesforce CRM Content – Brief Description about CRM Content and How can Developer and Admin Use CRM Content

Salesforce CRM Content Organize, share, search, and manage content within your organization .Content includes all file types, from traditional business documents such as Microsoft PowerPoint presentations to audio files, video files, Web pages, and Google docs.

It Simplifies content management by incorporating user-friendly features into the following :

  • Organizing
  • Searching
  • Subscribing
  • Contributing

Most of the People Think Why should I Use Salesforce CRM Content? what is the Benefits of using CRM Content ?


I Suggest to those People Please Refer the Below amazing Articles.

So After Understanding the concept let’s Move to the other Step

How to enable CRM Content in your Organization?

Refer Below Link and Enable CRM Content in your Organization Step by Step.

What Salesforce Admin Should Know about CRM Content?

  • Publish Files to Libraries –

Go to the Libraries Tab and click on Contribute .


Choose File from your Local system and Enter Description , Select Library in which you want to Publish the file and Click on Save .



You can Share File with your Standard OR Custom Object But you need to make Lookup field of that Object with Standard Object (Content Version) of CRM Content .

  • Create a New Library –

Click on New Button and enter Name, Description and Unique Name of the Library.


  • Update Content Version –

Select any file Uploaded in CRM Content  From the Top Content Section  Or you can View file from Library and Click on Edit and Select Update Content Version and Choose file and Update the Version of that Content.

Using this you can publish a new Version of the file and update file Properties.



  • CRM Content Permissions ,Custom fields ,Customization of content Page Layouts

Search Salesforce Files in the left side Search Bar.


You would These Options After clicking on Salesforce Files


So These are the all customization which you can do regarding Library Permissions for Users, Create, modify and Delete Fields on Content Version, Manage Validation Rules etc..

Create, modify and delete custom fields is the option where you can make Standard or custom objects Lookup with Content Version So that you can upload file with the object from libraries tab.

As you see in Below Picture I can Upload File with Lead Or Account Object.


What about Developers ?


What Developer should Know about CRM content for working with Apex ?

Below is the CRM Content Object Hierarchy or you can say Data Model . This is thing which Developer must know for working with CRM Content.



ContentWorkspace – ContentWorkspace is a Library which you can use for publish File . You can use Workspace(Library) Id while making Instance of Content Version so the File publish in that Workspace.


ContentWorkspaceDoc – ContentWorkspaceDoc  Represents a link between a document and a public library in Salesforce CRM Content . It allows a document to be shared with multiple libraries.

In the ContentWorkspaceDoc there are two lookup Fields that is ContentWorkspaceId and ContentDocumentId.


ContentDocument – ContentDocument is a document that has been uploaded in library in CRM Content.

For upload file as Content Document you have to Make Instance of Content Version Because Create() call not supported in Content Document.


ContentVersion – This is a Specific Version of a Content Document(File) in CRM Content.


So these are some things Developer or Admin should Know.

Please Refer the Below Links for Complete Details of Content Object.

Hope you find this helpful, in case of any queries/concerns, please post a reply or drop an email to me at .