Friday, December 7, 2012

Getting Salesforce URL using Javascript in Visualforce Page

This will return the salesforce base URL which can be used visualforce pages

function salesforcebaseURL()
{

    var d = $gc(location).attr('href');

    pathArray = d.split( '/' );

    var Protocol = pathArray[0]; 

    var host = pathArray[2];

    return Protocol+'//'+host;

}

if we need to call any other visualforce page append with the "apex/page name"

var URL = salesforceURL()+'apex/samplepage';

Friday, September 21, 2012

Removing the last character from a String - Salesforce

Its easy to remove the last character from a string by using the Substring() method..
If X is a string  the last value can be removed by

                             String Y = X.Substring(0,X.length()-1);

Tuesday, September 18, 2012

EMAIL SERVICES IN SALESFORCE-EXAMPLE

I shared about the Salesforce's Email Services in my previous post..Creating Record by sending email to Salesforce - Part 1..

With this Email Service our part is to create an Apex Class to fetch the details from the email which we sent to Salesforce.

To fetch the data from incoming email we should make use of the Inbound Email messaging feature.

For Example:


global class recordfromEmail implements Messaging.InboundEmailHandler {

  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
    Messaging.InboundEnvelope envelope) {

    Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();

Oppotunity Oppty = New Oppotunity();

       String[] emailBody = email.plainTextBody.Split('\n',0); 
       
       oppty.Name = emailBody[0]; 
      
       oppty.Stage = emailBody[1]; 

       insert oppty;

  return Result;
 }

}

EMAIL SERVICES IN SALESFORCE


Yes , it is possible to create a record  just by sending an email to your Salesforce login.....

All can be done with the Salesforce's awesome feature called 'Email Services'.

With This Email Services in Salesforce all we have to do is,

  • Associate one Email id with Salesforce.
  • An Email from Salesforce will be generated and should be associated for.Sending mails to the salesforce.

Email Services can be created by

SetUp --- Develop --- Email Services



The generated email from Salesforce will be like

testemail@9q9zr6cc1w67kjgunhpqftj32.in.sandbox.salesforce.com


Email Service also facilitate users to get known to the errors occurring  while processing the email.

Users can specify an alternate email address to which the errors can be diverted..

Users need to write an Apex class to fetch the details in the email with the help of inBound email Class function.


That's it we can create a Email Service.......

Friday, August 31, 2012

Only Aggregate Expressions use field aliasing Error in Salesforce

Today I came occurs this funky error "Only Aggregate Expressions use field aliasing",,,,,,

Everthing in my trigger are fine but I m not able find where I am wrong.....

For the last go I checked my code from top to bottom, then only I found where I went wrong......

Actually I forget to put a comma in my SOQL Query, like

QueryList = Select a.Id, a.Name , a.phone a.email from account a;

The error got resolved once I corrected my silly mistake......

Cheerssssss

Too Many SOQL Queries: 101 in Salesforce

While writing a trigger or a class one may encounter the error "Too Many SOQL Queries : 101" which occurs when the governor limit for SOQL Queries crosses its threshold...........

one of the common errors would be including the SOQL Query inside a for loop..

so avoid this error 

Avoid writing  the SOQL query inside a For loop......



Friday, July 6, 2012

How to Give two profile access to a single User in Salesforce

Just had a thought of sharing it....... 

In my organization I have two profiles viz Profile A and Profile B and each profiles have different customization. I have an User "User X" in my organization.

I wanted to give the User X the access to both the profiles.

But I thought how we can make it without "Creating a Common Profile with Common Object Permission".

Then I came across a concept called "Permission Sets" which extends the Users functional access without changing the profiles..



It can be accessed by Manage Users-> Permission Sets



Wednesday, March 28, 2012

Inserting/Import Attachments using Apex Dataloader in Salesforce


Once I came to know we can able to extract the Notes and attachments from an object using Dataloader, I thought importing the attachment is also the same and we can do it very easily in the same manner but I was wrong.


Let us see how we can do this using dataloader,but before that please recall How to Import/Export Notes and Attachment through DataLoader in Salesforce

For importing or inserting an attachment to an object (say Account) we need the following details in the CSV file that we are going to use in the Data loader.

PARENTID
NAME
CONTENTTYPE
BODY
OWNERID


PARENTID:
This is nothing but the Salesforce ID of the Parent object record(Say AccountID).

NAME:
Name is the name of the attachment file.

CONTENT TYPE:

The File Format eg: Doc,txt,xls,pdf..

BODY:
This one plays an important role while importing an attachment.
We must give the Path of the attachment in the local Machine.
Make sure the File must follow with its extensions i.e .pdf,.doc.xls, etc

Example: C:\Program Files\salesforce.com\Data Loader\Test1\Attachments\TestDoc.doc


OWNERID:

The user Profile.

 After filling up all these details in the CSV file load this file in data loader and Map the respective fields and Insert the file into Salesforce with Dataloader.

How to Import/Export Notes and Attachment through DataLoader in Salesforce


          We all know that we can do Insert, Upsert, Delete, Extract data from and to the Salesforce environment with the help of Apex Data Loader. When I was thinking is it possible to do all the above operations with Attachments and Notes which can be attached to some objects like Accounts, Opportunities, etc. I got to know that we can do the CRUD operations in Attachments and Notes also.

Let us see how we can achieve this using the Apex Data Loader.

In Data Loader after we select the operation which we need to perform by default we are not able to see the “Notes” and “Attachment” objects “Select Salesforce Objects” dialog box.

In order to view the Notes and Attachment objects Just Check in the “Show All Salesforce objects” check box available just at the top of the Object select field.


That’s it we can now be able to do all the CRUD operations in Notes and Attachment..


Most important 

Find the full details of performing the CRUD operations here

Sunday, March 18, 2012

Batch Upload of Data to related objects in Salesforce

I have been storming my mind for about a week to get an answer for performing batch upload of data into related objects for my Salesforce Environment . Once I found I felt shame on me asking " Why Don't you think in that way, wasting a week?"

Before looking into that first have a glance of "Automation of Data Loader From Command Line for Salesforce"

I was thinking how we can upload data into related objects (like Account and Opportunity) that are having Parent-Child Relationship and I found this simple solution.

All we know that if we want to load a child record to a parent we need the Salesforce ID created for that parent object.For example if we want to load an opportunity to an account first we need to give the Account IDof the account in the CSV file that we are uploading for the opportunity.

But it will be very complex if we want to do all four activities in one go i.e. 
i.Inserting an account
ii.Extracting the account id
iii.Mapping the Account id to the Opportunity data
iv.Inserting the Opportunity data

To do all this, we need to alter the mapping file only
In the mapping file used for inserting an opportunity we need to change the mapp for the Account ID field.

i.e the syntax should be like this.

AccountID=Account:\Extrnal_Id__c

where External_Id__c field is the External ID field in the Account object.

That's it we can run the batch process for data loading in related objects....

Saturday, March 17, 2012

Batch Processing for Data Loader in Salesforce


We can run a batch process of Data Loader using command line to automate Data Loader to perform CRUD operations. All we have to do is to create a batch file to call all the process that we need to execute in the batch process by mentioning the Bean Id.
For example:

"cls
call process "Path where Config.properties file available" AccountExtractProcess 
cls

call process "Path where Config.properties file available" OpportunityExtractProcess"


That's it we can run data loader as batch process for Salesforce.

Automation of Data Loader From Command prompt for Salesforce


This post is for Data Loading using command prompt, I have already shared the required files for this automated process in "Data Loader Using Command Prompt",here  I will be sharing how to run this in command prompt.

For running in command prompt we need "Process.bat" file which can be accessed in
"C:\Progam Files\salesforce.com\DataLoader\bin"

Okay for your testing purpose create a test folder with any name say " Test " and copy down all the required files that I have mentioned in the "Data Loader Using Command Line" post.

Now open Command prompt and navigate to "bin" folder in command prompt then run the "Process.bat" file with the syntax

Process.bat "Path to the Test folder" <Bean Id for the process that we are going to execute>

ex: Process.bat "C:\Progam Files\salesforce.com\DataLoader\Test\" AccountExtractProcess

That's it now you can do CRUD operations from Command Line ..

Using Apex Data loader from command prompt


Recently I came with a task of uploading data in salesforce automatically, I found that we can use command prompt for this purpose. All we need is to have the following files

         Config.properties
         Process-conf
         Mapping Files
         Data Files

Config.Properties:

This file contains all the configuration properties for Data Loader including the UserName and Encrypted Password of your Salesforce Environment and Proxy Address Info.
This file can be accessed from
for XP: "C:\Program Files\Salesforce.com\Data Loader\conf
for Vista: "C:\Users\'UserName'\AppData\Roaming\Salesforce.com\Apex Dataloader\"

Process-conf:

This XML file contains all the operations we will be doing in Data Loader i.e Insert Operation,Delete Operation,Upsert operation,Extract Operation, Update operation. This file is can be accessed from

for XP: "C:\Program Files\Salesforce.com\Data Loader\conf
for Vista: "C:\Users\'UserName'\AppData\Roaming\Salesforce.com\Apex Dataloader\"

Mapping Files:

These are ".SDL" files which can be used to Map the data in our ".CSV" file with different fields in our salesforce environment.This files can be generated automatically once we use Data Loader for any CRUD operation.

Data Files:

These files are the files that contain our actual data to be used for any of the CRUD operation.These files should be of .CSV type.

Check Out How to run this Data loading from command prompt

Friday, March 16, 2012

Im In Cloud

Yes Guys I'm in cloud, after being worked for about 1 year with Salesforce.com I'm pretty interested with this CRM tool. Now I created this blog just to share the knowledge which I learnt from Salesforce.

I want to share another important thing too, that is nothing but I am a Salesforce.com certified Developer, Hard to believe it right!!! But you have to do that....



I will not be sharing much of the coding stuffs here but I will share whatever I will come across some small small stuffs in Salesforce.