Salesforce Certified Application Architect

Monday 27 January 2014

Relationship between Accounts,Contacts In salesforce


Account and contact behaves as master detail in business logics but on UI it is a lookup relationship. Let me explain you a bit more.

You can create a contact without filling account i.e it shows that there is a lookup relationship between account and contact.

If you have created a contact with account and you delete that account then contact will be deleted, this shows that it is in Master-Detail relationship. This is a standard behavior.

So we can say it in both ways, but it documentation it is a lookup relationship.


I hope it is helpful for you 


Thanks
Gaurav

Wednesday 22 January 2014

How to integrate SFDC with external webservice?


Salesforce: APEX HTTP callout example, POST and GET
Steps to implement apex HTTP callout:
How to integrate SFDC with external webservice?



Using this you can integrate your SFDC instance with external systems, that can be your SAP, Oracle Apps or any other in-house application which need your sfdc data more or less immediately to process request.

This callout is for Rest webservice:
 
1) External system enabled with REST webservice with JSON/XML response ( we are using Json in this example)
2) Register, our external endpoint URL with SFDC "Remote sites". ( endpoint URL, is the external system URL which will serving your request)

3) Invoking HTTP Callouts using following code:


Following is the sample/example apex class which is making callouts to external system rest webservice. This example also shows you , how Serializeand deSerialize Json. (Object to Json String and vise-verse).

public with sharing class TestHttpCallOut {

String endPoint = 'http://***yousite_app***.com/sfdc';

public void postDataToRemote(String name,String email,Integer age){
   performAction('POST',name,email,age);  
}
public void fetchDataFromRemote(){
   performAction('GET');  
}


 public void performAction(String method,String name,String email,Integer age){
           
             //Prepare http req
             HttpRequest req = new HttpRequest();
             req.setEndpoint(endPoint);
             req.setMethod(method);
           
                Map<String,object> mapEmp = new Map<String,object>();
                mapEmp.put('name',name);
                mapEmp.put('email',email);
                mapEmp.put('age',age);
                String JSONString = JSON.serialize(mapEmp);  
       
           
            req.setBody(JSONString);
           
            Http http = new Http();
            HTTPResponse res = http.send(req);
           
            System.debug(res.getBody());
       
  }
 
public void performAction(String method){

             HttpRequest req = new HttpRequest();
             req.setEndpoint(endPoint);
             req.setMethod(method);
           
            Http http = new Http();
            HTTPResponse res = http.send(req);
            Map<String,String> responseMap =   (Map<String,String>)JSON.deSerialize(res.getBody(),Map<String,String>.class);
             
              System.debug(responseMap);
             
  }
   
 
}

Use folloiwng commented code to execute this example,

/*
//TestHttpCallOut  a = new TestHttpCallOut ();
//a.fetchDataFromRemote();
//a.postDataToRemote('BOB','abc@xyz.com',101);
*/

Salesforce trigger list/map values on insert/update/delete/undelete


This table shows us when Id exists in trigger:

insert
update
delete
undelete
before
null
Id
Id
-
after
Id
Id
Id
Id

And this one shows what values of Map/List we have on different stages of trigger work:

Execution
Method
insert
update
delete
undelete
before
trigger.new()
List
List
null
-
before
trigger.newMap()
null
Map
null
-
before
trigger.old()
null
List
List
-
before
trigger.oldMap()
null
Map
Map
-
after
trigger.new()
List
List
null
List
after
trigger.newMap()
Map
Map
null
Map
after
trigger.old()
null
List
List
null
after
trigger.oldMap()
null
Map
Map
null

Thursday 2 January 2014

Mixed DML Operations in Test Methods

Test methods allow for performing mixed DML operations between the sObjects listed in sObjects That Cannot Be Used
Together in DML Operations and other sObjects if the code that performs the DML operations is enclosed within
System.runAs method blocks. This enables you, for example, to create a user with a role and other sObjects in the same
test.

===========================================================================================
Hi All,

Here is the syntax to avoid test class errors in Mixed DML Operation salesforce,


@isTest
public class MyTest
{
  Public static testmethod void Test_MyTest()
   {
      User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
      System.runAs (thisUser) 
      {
      
    // Add your test class content here
     }
   }
}

=========================================================================================
Example:

@isTest
private class RunasTest {
static testMethod void mixeddmltest() {
// Create the account and group.
Account ac = new Account(Name='TEST ACCOUNT');
// Group is created in the insert trigger.
insert ac;
// Set up user
User u1 = [SELECT Id FROM User WHERE UserName='testadmin@acme.com'];
System.RunAs(u1){
// Add startTest and stopTest to avoid mixed DML error
Test.startTest();



What is the Legend in salesforce.

By default, VisualForce charts include a legend, represented as a box that displays a list of labels
with their corresponding visual representation to serve as a key for the user viewing the chart.

The <apex:legend> component allows you to define attributes specific to the Legend, and
must be a child of the <apex:chart> container.

Series
The type of chart rendered is defined by its Series. The Series is a child element of the
<apex:chart> container, and is defined by specific VisualForce components and their associated
attributes:
Bar Chart: <apex:barSeries>
Line Chart: <apex:lineSeries>
Area Chart: <apex:areaSeries>
Scatter Chart: <apex:scatterSeries>
Pie Chart: <apex:pieSeries>
Gauge Chart: <apex:gaugeSeries>
Radar Chart: <apex:radarSeries>

A standard controller’s tasks are as follows:

Controlling Data: Standard controllers fetch data and provide it to the page, list, dialog or
form, all referred to here as views. While it is the view’s task to manage the presentation of
its data, the controller gathers the data from the view as entered or changed by a user, and
passes it to the data model for processing.

•Controlling Actions: Standard controllers respond to user or programmatic commands
initiated from a view. Such commands, referred to as Actions, might be associated with
processing the data gathered from the view, or simply to respond to a navigation link.

•Controlling Navigation: Standard controllers navigate the user to any specific view associated
with an action. They also handle redirection to subsequent views, based on the specific
outcome of various actions and data operations.

Five Things You Should Master Before Getting Started with Visualforce

1. Develop a solid understanding of the platform.
2. Learn and know your tools.
3. Learn some code: SOQL, Visualforce, and Apex.
4. Choose Apps that are well-suited to Salesforce Platform.
5. Learn from the pro’s.

Salesforce Certified Application Architect & Certified Data Architecture and Management Designer Exam

How to pass Salesforce Certified Data Architecture and Management Designer Exam This exam was 1st architect exam for me. Its not that muc...