EzDevInfo.com

salesforce interview questions

Top salesforce frequently asked interview questions

Disadvantages of the Force.com platform [closed]

We're currently looking at using the Force.com platform as our development platform and the sales guys and the force.com website are full of reasons why it's the best platform in the world. What I'm looking for, though, is some real disadvantages to using such a platform.


Source: (StackOverflow)

Visualforce Page embedded in a detail page that needs to redirect to other page

I have a Visualforce page that is embedded on the detail page of Opportunities.

Within the page is a command button that invokes a method in the backing controller extension.

Once the backing method is complete, how can I redirect the user to another page?

I can return a PageReference from the method but it will only redirect the iframe that the embedded Visualforce page is displayed in.

Ideally I'd like to refresh the top level window but I'm concerned there may be cross domain issues if the embedded visualforce page isn't in the same domain as the parent window.


As a basic test in I tried adding the following to the embedded Visualforce page:

<script>
    window.setTimeout(testRedirect,2000);
    function testRedirect() {
        top.location.reload();
    }
</script>

This resulted in Chrome logging the error:

Unsafe JavaScript attempt to access frame with URL https://na2.salesforce.com/006400000000000 from frame with URL https://ab2.na2.visual.force.com/servlet/servlet.Integration?lid=066400000000000&ic=1. Domains, protocols and ports must match.

So the domains differ for the Visualforce page.


Source: (StackOverflow)

Advertisements

Where to get client_id and client_secret of Salesforce API for Rails 3.2.11

I've been following a tutorial from: http://wiki.developerforce.com/page/Accessing_Salesforce_Data_From_Ruby

But, I'm stuck with the part where you need to supply the keys:

host: login.salesforce.com        # Use test.salesforce.com for sandbox
client_secret: 1234567890         # This is the Consumer Secret from Salesforce
client_id: somebigidthinghere     # This is the Consumer Key from Salesforce
sobject_module: SFDC_Models       # See below for details on using modules
debugging: true                   # Can be useful while developing
username: me@mycompany.com
password: mypasswordplusmysecuritytoken

Where can I get the client_secret and client_id. The tutorial from the official API site of Salesforce is kind of outdated. http://www.salesforce.com/us/developer/docs/api_rest/index.htm

And some other tutorials didn't even mention where to exactly get it.

I already created an account in http://developer.force.com/

And even created a custom app, correct me if I'm wrong.

Then don't know where to find the keys that I need.

Any workarounds will be appreciated.


Source: (StackOverflow)

Salesforce.com Id attribute seems to have a 15 and 18 character value, whats the difference?

When using the SOAP API to work with salesforce.com (SFDC) it seems that the primary key in the underlying database is Id. Well there seems to be two representations of this value as either a 15 character version or an 18 character version.

I have been using the 18 since it is clearly more specific, but what is contained in the last three digits, that they can be dropped, seemingly?

Anyone understand what this is all about?


Source: (StackOverflow)

Accessing Salesforce Webservice API using C#

I havent worked with that Salesforce API before, so I am a bit stuck on how to connect to the salesforce service.

So far I understood that I have to generate a wsdl file for my account or rather the account of my customer (step 1). So far, so good.

But now the Quickstart (http://www.salesforce.com/us/developer/docs/api/Content/sforce%5Fapi%5Fquickstart%5Fsteps.htm) says something about "Import the WSDL File into your development platform" (step 2).

How do I import a wsdl file into Visual Studio 2008? I cant find the "Add Web Reference" option which is mentioned in the quickstart.

And if I only need to use the WSDL, what use has the Salesforce Dotnet API package which can be downloaded from the salesforce website (http://wiki.developerforce.com/index.php/Salesforce%5FDotnet%5FAPI)?

Are there any gotchas I should watch out for when developing applications that use the salesforce API?


Source: (StackOverflow)

Hard delete custom field in Salesforce

I am having problem in deleting custom fields permanently.

Like for e.g. I have created a custom field in Contact entity with name "Newsletter" which Salesforce internaly stores as "Newsletter__c" as custom field.

Then I use the below code to delete custom field of contact.

var cstField = new CustomField
{
  type = FieldType.Checkbox,
  fullName = "Contact.Newsletter__c"
};

// Delete the object
var r = metaService.delete(new Metadata[] { cstField })[0];

The above code deletes the custom field, but keeps it under "DeletedFields" category where you can again "Erase" or "Undelete" the custom field. These custom fields are deleted automatically after 15 days.

I want to delete the custom fields from these category also as if I again create cf with same name SF gives error like "Already exists".

I tried purgeOnDelete option too while deploying but no luck so far.


Source: (StackOverflow)

Salesforce REST API Login?

I am examining a sample which is in the salesforce developer site.

In that sample when we click a link it will be redirected to the salesforce login page. If the login successful, then an access token is issued.

I dont want my application to redirect to the salesforce login page. In the existing sample the environment variable is set to,

"https://login.salesforce.com"

What should I do to avoid redirecting to salesforce login page.


Source: (StackOverflow)

How do I detect the environment in Salesforce?

I am integrating our back end systems with Salesforce using the web services. I have production and stage environments running on different URLs. I need to be able to have the endpoint of the web service call be different depending on whether the code is running in the production or sandbox Salesforce instance.

How do I detect the environment.

Currently I am considering looking up a user to see if there user name ends in 'devsandbox' as I have been unable to identify a system object that I can query to get the environment.

Further clarification:

The location I need to determine this is within the Apex code that is invoked when I select a button in Salesforce. My custom controller needs to know if it running in the production or sandbox Salesforce environment.


Source: (StackOverflow)

Salesforce Authentication Failing

I am trying to use OAuth authentication to get the Salesforce Authentication Token, so I referred wiki docs @ http://wiki.developerforce.com/page/Digging_Deeper_into_OAuth_2.0_on_Force.com but after getting authorization code, when I make a Post request with 5 required parameters, I'm getting following exception {"error":"invalid_grant","error_description":"authentication failure"} CODE 400 JSON = {"error":"invalid_grant","error_description":"authentication failure"} which is I guess a bad request.

PostMethod post = new PostMethod("https://login.salesforce.com/services/oauth2/token");
post.addParameter("code",##############);
post.addParameter("grant_type","authorization_code");
post.addParameter("redirect_uri","#################");  
post.addParameter("client_id",this.client_id);
post.addParameter("client_secret",this.client_secret);
httpclient.executeMethod(post);
String responseBody = post.getResponseBodyAsString();
System.out.println(responseBody+" CODE "+post.getStatusCode());

Kindly reply, if exception known ?


Source: (StackOverflow)

How can multiple developers efficiently work on one force.com application?

The company I work for is building a managed force.com application as an integration with the service we provide.

We are having issues working concurrently on the same set of files due to the shoddy tooling that is provided with the force.com Eclipse plugin. If 2 developers are working on the same file, one is given a message that he can't save -- once he merges he has to manually force the plugin to push his changes to the server along with clicking 2 'Are you really sure' messages.

Basically, the tooling does a shoddy job of merging in changes and forces minutes of work every time the developer wants to save if another person has modified the file he's working on.

We're currently working around this by basically 'locking' individual files by letting co-workers know who is editing a file.

It feels like there has got to be a better way in this day and age. Does anyone know of a different toolset we could use, process we could change, or anything we can do to make this easier?


Source: (StackOverflow)

How do I avoid STANDARD_PRICE_NOT_DEFINED when unit-testing an OpportunityLineItem in Apex v24.0?

Apparently a new feature of the Spring '12 / v24.0 release of Apex in Salesforce.com is that unit tests no longer have access to 'real' data -- thus (if I'm understanding the change correctly) a SOQL query will now only retrieve objects that have been inserted during the course of the unit test -- and even that is subject to some limitations.

At any rate this seems to throw OpportunityLineItem testing out the window, because:

  • It's impossible to insert an OpportunityLineItem without a PriceBookEntryId, BUT
  • You can't insert a new price-book entry for product X unless you already have a Standard Price Book entry for product X, BUT
  • There isn't a Standard Price Book in the test data because the Pricebook2 table, like all tables, is effectively empty at the beginning of the unit-test run, AND
  • There's no way to create a Standard Price Book in Apex

I'm really hoping I got at least one of those four points wrong, but so far no variation on my existing unit-tests has shown any of them to be wrong. Which of course means my unit tests no longer work. This happened literally overnight -- the tests ran fine in my sandbox on Friday, and now they fail.

Am I missing something, or is this a bug in the new SFDC release?


Source: (StackOverflow)

Salesforce - How to Deploy between Environments (Sandboxes, Live etc)

We're looking into setting up a proper deployment process.

From what I've read there seems to be 4 methods of doing this.

  1. Copy & Paste -- We don't want to do this
  2. Using the "Package" mechanism built into the Salesforce Web Interface
  3. Eclipse Force IDE "Deploy to Server" option
  4. Ant Script (haven't tried this one yet)

Does anyone have advice on the limitation of the various methods .

Can you include everything in a Web Interface package?

We're looking to deploy the following items:

Apex Classes

Apex Triggers

WorkFlows

Email Templates

MailMerge Templates -- Can't seem to find these in Eclipse

Custom Fields

Page Layout

RecordTypes (can't seem to find these in Website or Eclipse)

PickList items?

SControls


Source: (StackOverflow)

Best Practices for Managed SalesForce App Development?

We're developing applications for AppExchange and are trying to figure out the best way to do development and release management. There are several issues around this:

1) Package Prefixes. We are developing code in unmanaged mode and releasing as managed, so we have to add all the package prefixes into the code. Is there a way to do this dynamically at runtime? Right now we're using an Ant script, which stops us benefitting from the force.com IDE plugin.

2) Resource files... We are doing some ajax-ey stuff and as a result have a few different resource files we upload, some of which are multiple file resources (zip files). Has anyone automated the building of these resources using ANT, and does that work well?

Our environment seems very fragile and works for some developers and not others; have other people had this problem? How did you resolve it?


Source: (StackOverflow)

Apex unit test sees no data

I have created a task in my org with subject "Email Task"

i have written apex code as

public class  TaskInfoDAOClass
{
   public static List<Task> queryTaskInfo ()
    {
integer count = [SELECT count() FROM Task];
System.debug('Row Count :'+ count);
 List<Task> tasks= [SELECT Task.Id,Task.AccountId,Task.Status,Task.Account.Name FROM Task where Task.Subject='Email Task'];
  return tasks;     
  }
}

I have created one test class to test apex code as

@isTest 
public class TestTaskInfoDAO
{
 public static testMethod void testQueryTaskInfo()
 {
List<Task> tasks = TaskInfoDAOClass.queryTaskInfo();
 System.debug ('this is a debug statement');

for (Task t : tasks)
{
 System.debug ('Status '+ t.Status);
  System.debug ('Account name '+ t.Account.Name);

 }
}
} 

when I run this test I am getting 0 as ROW count. please refer apex.log file

24.0 APEX_CODE,FINE;APEX_PROFILING,FINE;DB,INFO;VALIDATION,INFO;WORKFLOW,FINEST
23:48:30.100 (100678000)|EXECUTION_STARTED
23:48:30.100 (100722000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000000k5Qw|TestTaskInfoDAO.testQueryTaskInfo
23:48:30.101 (101272000)|METHOD_ENTRY|[2]|01p90000000k5Qw|TestTaskInfoDAO.TestTaskInfoDAO()
23:48:30.101 (101414000)|METHOD_EXIT|[2]|TestTaskInfoDAO
23:48:30.101 (101494000)|METHOD_ENTRY|[1]|01p90000000k5Qr|TaskInfoDAOClass.TaskInfoDAOClass()
23:48:30.101 (101513000)|METHOD_EXIT|[1]|TaskInfoDAOClass
23:48:30.101 (101782000)|METHOD_ENTRY|[6]|01p90000000k5Qr|TaskInfoDAOClass.queryTaskInfo()
23:48:30.102 (102176000)|SOQL_EXECUTE_BEGIN|[5]|Aggregations:0|select count() from Task
23:48:30.106 (106893000)|SOQL_EXECUTE_END|[5]|Rows:0
23:48:30.106 (106965000)|SYSTEM_METHOD_ENTRY|[6]|String.valueOf(Object)
23:48:30.107 (107012000)|SYSTEM_METHOD_EXIT|[6]|String.valueOf(Object)
23:48:30.107 (107032000)|SYSTEM_METHOD_ENTRY|[6]|System.debug(ANY)
23:48:30.107 (107040000)|USER_DEBUG|[6]|DEBUG|Row Count :0
23:48:30.107 (107047000)|SYSTEM_METHOD_EXIT|[6]|System.debug(ANY)
23:48:30.107 (107385000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Task.Id, Task.AccountId, Task.Status, Task.Account.Name from Task where Task.Subject = 'Email Task'
23:48:30.109 (109847000)|SOQL_EXECUTE_END|[9]|Rows:0
23:48:30.109 (109930000)|METHOD_EXIT|[6]|01p90000000k5Qr|TaskInfoDAOClass.queryTaskInfo()
23:48:30.110 (110074000)|USER_DEBUG|[7]|DEBUG|this is a debug statement
23:48:30.789 (111361000)|CUMULATIVE_LIMIT_USAGE
23:48:30.789|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 2 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of script statements: 7 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

23:48:30.789|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
23:48:30.789|STATIC_VARIABLE_LIST|
  double:MAX_VALUE:0
  long:serialVersionUID:0
    int:MAX_EXPONENT:0
    int:MIN_EXPONENT:0
    Boolean:TRUE:0
    long:serialVersionUID:0
    double:POSITIVE_INFINITY:0
    double:MIN_NORMAL:0
    double:MIN_VALUE:0
    Boolean:FALSE:0
    int:SIZE:0
    char[]:DigitOnes:0
    int[]:sizeTable:0
    char[]:DigitTens:0
    double:NaN:0
    int:MAX_VALUE:0
    char[]:digits:0
    long:serialVersionUID:0
    double:NEGATIVE_INFINITY:0
    int:MIN_VALUE:0
    int:SIZE:0

23:48:30.789|CUMULATIVE_LIMIT_USAGE_END

23:48:30.111 (111444000)|CODE_UNIT_FINISHED|TestTaskInfoDAO.testQueryTaskInfo
23:48:30.111 (111452000)|EXECUTION_FINISHED
23:48:30.999|CUMULATIVE_PROFILING_BEGIN
23:48:30.999|CUMULATIVE_PROFILING|SOQL operations|
  Class.TaskInfoDAOClass.queryTaskInfo: line 5, column 1: [SELECT count() FROM Task]: executed 1 time in 5 ms
  Class.TaskInfoDAOClass.queryTaskInfo: line 9, column 1: [SELECT Task.Id,Task.AccountId,Task.Status,Task.Account.Name FROM Task where Task.Subject='Email Task']: executed 1 time in 3 ms

23:48:30.999|CUMULATIVE_PROFILING|No profiling information for SOSL operations
23:48:30.999|CUMULATIVE_PROFILING|No profiling information for DML operations
23:48:30.999|CUMULATIVE_PROFILING|method invocations|
  External entry point: public static testMethod void testQueryTaskInfo(): executed 1 time in 11 ms
  Class.TestTaskInfoDAO.testQueryTaskInfo: line 6, column 1: public static LIST<Task> queryTaskInfo(): executed 1 time in 8 ms
  Class.TestTaskInfoDAO.testQueryTaskInfo: line 9, column 1: global object iterator(): executed 2 times in 1 ms
  Class.TaskInfoDAOClass.queryTaskInfo: line 6, column 1: global public static String valueOf(Object): executed 2 times in 0 ms
  Class.TestTaskInfoDAO.testQueryTaskInfo: line 7, column 1: global public static void debug(ANY): executed 1 time in 0 ms

23:48:30.999|CUMULATIVE_PROFILING_END

Why I am getting 0 ROW COUNT ?


Source: (StackOverflow)

Web hook in salesforce?

I want to get notified when a new lead is created in Salesforce. Is there something like webhook in Salesforce or some other way to achieve this ?

Any help is appreciated


Source: (StackOverflow)