anusha(salesforce developer)

Sunday, 20 January 2019

WBDSERVICES

WSDL is a XML based language used to create service descriptions. we have two types of wsdl.

Two types of wsdl
1.Enterprise WSDL: A strongly typed wsdl for customers who want to build an integration with their Salesforce.com organization only
strongly typed means: here we can work with objects and fields with specific data types like int and string.

2.Partner WSDL : A loosely typed wsdl for customers, partners who are building client applications for multiple organisations.
loosely typed
 means: here we can work with objects, fields and vlaues with any data type.

Generally we save all the WSDL files with .wsdl extension.

To generate wsdl files ,      setup-->develop-->API
Generation of wsdl from apex,     setup-->develop-->apex classes-->generate from wsdl


Q: Differences between xml and wsdl?
XML (eXtensible Markup Language) is a set of rules for encoding documents.
WSDL is a XML based language used to create service descriptions

Q: how many ways we can generate session id in salesforce using soap
We can use login() method

syntax:
---------
loginresult = connection.login(string username, string password)

Q: What is the difference between single/two/three steps authentication?
Single step authentication is with Username and password.
Two step authentication is with Username , password & a time-based token generated from an authenticator app when they log into Salesforce.

SOAP(Simple Object Access Protocal)
WSDL(Web Service Description Language)
XML(Extensible Markup Language)
SOA(Service Oriented Architecture)
REST(Representational State Transfer)

Purpose:
---------
SOAP API and REST API both are commonly used to expose our data from force.com platform to other platforms(JAVA ,.NET ,etc)
--> SOAP is a XML based messaging protocal used by webservices.
--> SOAP relies on XML to provide messaging services.
     . The purpose of using XML in SOAP is that it is used to make requests and receive responses in SOAP.
--> One of the best features of SOAP is "built-in error handling"
Ex: Let us assume that If there’s a problem with your request, then what happens the response contains error information in order to fix the problem we use this one.


-->Generally REST provides a lighter weight alternative.
-->REST relies on a simple URL in many cases to make request.
-->REST ful web services communicate by HTTP do not require XML messages or WSDL service API definitions.
-->REST can return XML, Plain text, JSON(javascript object notation), HTML etc.

SOA:
------
-->Lets say we have a software called "service consumer" it wants to talk to another software lets called that "service provider" , cosumer software is going to send a service request or message to the provider software and the provider software is going to reply back with service response. When the request is received by service provider software it is processed by service .
-->service: it is a well defined funtion that does not depend on the state of other services.
-->consumer software needs to know that how to call the service for example what parameters , arguments the service is expecting

SOA deff:
-----------
SOA is a solution for making two software commuicate to each other.
Web services is an implementation of SOA.

-->The webservice which is developed with any technology like java,php,.net etc that is available to us in the form of WSDL.


"Each key is a property of JSON object"
ex:  var obj1={user(key):"sathya", age(key):23, country(key):"india" etc....};

Sunday, 4 June 2017

Component Facets in lighting

facetHeader.cmp
<aura:component>
<aura:attribute name="header" type="Aura.Component[]"/>
<div>
<span class="header">{!v.header}</span><br/>
<span class="body">{!v.body}</span>
</div>
</aura:component>

facetHeaders.cmp
<aura:component>
See how we set the header facet.<br/>
<c:facetHeader>
Nice body!
<aura:set attribute="header">
Hello Header!
</aura:set>
</c:facetHeader>
</aura:component>

Application
<aura:application >
<c:facetHeaders></c:facetHeaders>
</aura:application>

Thursday, 11 May 2017

Adding lightning application in vf page

<aura:application access="GLOBAL" extends="ltng:outApp"> 
    <aura:dependency resource="ui:button"/>
</aura:application>

VF Page :

<apex:page>
    <apex:includeLightning />

    <div id="lightning" />

    <script>
        $Lightning.use("c:app15", function() {
        $Lightning.createComponent("ui:button",{ label : "Press Me!" },
                                   "lightning",function(cmp) {});
        });
    </script>
</apex:page>

Wednesday, 19 April 2017

Example for Aura Lightining

expressions: 
{! }
{!v.}
{!c.}
{! this}

Applying CSS
-------------------

Example  1 :Creating a component :

Component : 
<aura:component >
<h1> This is my data </h1>
</aura:component>

Application :

<aura:application >
<c:Cap1></c:Cap1>
</aura:application>


Example 2: Applying CSS on component :

<aura:component>
  <div class="white">
    Hello, HTML!
  </div>
  
  <h2>Check out the style in this list.</h2>
  
  <ul>
    <li class="red">I'm red.</li>
    <li class="blue">I'm blue.</li>
    <li class="green">I'm green.</li>
  </ul>
</aura:component>

Style :
.THIS {
    background-color: grey;
}

.THIS.white {
    background-color: white;
}

.THIS .red {
    background-color: red;
}

.THIS .blue {
    background-color: blue;
}

.THIS .green {
    background-color: green;
}



Example :3: Creating attributes  for a component

Component Name: first1

<aura:component >
    <aura:attribute name="name" type="String" default="cyan" />
    {! v.name}
</aura:component>


Application :

<aura:application >
<c:first1></c:first1>
</aura:application>

Monday, 20 March 2017

Example code for Action support?

<apex:page controller="AccountSearch">
    <apex:form >
        <apex:pageBlock >
            <apex:outputPanel >
                Enter account Name: <apex:inputtext value="{!name}"/>
                <apex:actionsupport event="onclick" action="{!search}" rerender="out"/>
            </apex:outputPanel>    
            <apex:outputPanel id="out">
                <apex:pageBlockTable value="{!conlist}" var="c">
                    <apex:column value="{!c.name}"/>
                </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>



=============

public class AccountSearch {

    public string name {get;set;}
    public List<Contact> conlist{get;set;}
    
    public void search(){
    
        conlist= new list<contact>();
        
        conlist=[select id, name,phone from contact where account.name=: name];
    }
    
}

Example code for Action function ?

<apex:page controller="AccountSearch">
    <script>
         function javascriptfn(){
             alert('shall i Process');
             actionfun();// actionfunction name
         }
    </script>
    <apex:form >
        <apex:actionfunction name="actionfun" action="{!search}" rerender="out"/>
        <apex:pageBlock >
            <apex:outputPanel onclick="javascriptfn()">
                Enter account Name: <apex:inputtext value="{!name}"/>
                
            </apex:outputPanel>    
            <apex:outputPanel id="out">
                <apex:pageBlockTable value="{!conlist}" var="c">
                    <apex:column value="{!c.name}"/>
                </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Thursday, 2 February 2017

THE PROS & CONS of APEX,WORKFLOW RULES,VISUAL WORKFLOW,LIGHTNING PROCESS BUILDER


APEX
is really good at handling complicated logic and lots and lots of records. When you’re dealing thousands, hundred of thousands, millions of records – your looking at using APEX. You can use APEX for more simple use cases, but then that takes the flexibility away from the Admin. Most administrators do not know how to code in APEX. The major “con” for APEX is the requirement of needing an APEX developer. This also means there’s a time component. If you need a “quick change,” you’re depending on the developer’s schedule. The developer needs to update the code and test class. Then you’ll need to functionally test it and deploy. APEX is great for complicated and large processes, but there are often easier and more accessible methods for the smaller stuff.
WORKFLOW RULES
are fast, easy, and button-click friendly. The Workflow rule will “trigger” based on a set of criteria at which point the actions will either be immediate or based on a time-based schedule. Workflow rules can do a lot. They can update fields for the object it’s being “triggered” on and in certain circumstances update records for their parent record. Workflow rules can send out emails and create tasks. There’s also the rarely used Outbound message for integration.
One downside to the Workflow Rule is organization. Each set of criteria requires a new workflow rule. This means you’ll have many workflow rules for the same workflow process. For example, you want to have similar but different actions fire based on the stage of the Opportunity. This will require 1 Workflow rule per stage. The only way to organize this is by the naming convention of the rule – which can get messy.
A second downside to workflow rules are from the management perspective. You have no way of knowing what the actions are without “drilling” into each Workflow rule. That can be quickly annoying.
The final downside is the limitation. You are limited in what records you create and update, and you don’t have access to many of new features (chatter) available.
VISUAL WORKFLOW
is more complicated for most users to learn and use regularly. Unlike Workflow Rules, you have access to many other actions. You can create nearly any record and can update nearly any record. The two downsides to Visual Workflow are the difficulty it to learn the tool and it cannot be “fired” on it’s own.
LIGHTNING PROCESS BUILDER
is the new version of Workflow Rules. You can do a lot more different types of actions – including having a Flow from Visual Workflow get called. This gives you a lot of different powers. It’s built on top of Visual Workflow so you have almost all the same power of that tool. A Process can have multiple criteria diamonds – basically the equivalent of nesting multiple Workflow Rules together on one page. You can also see all the actions for each set of criteria that will be called.
One downside of the Process Builder is you currently only have access to the records and fields the running user has. Workflow rules would let you update an “invisible” field to the user. This was great for lots of data validation and controls. With Process Builder (and Visual Workflow) the field must be visible and editable by the user in order for the tool to update the field.
There are some other downsides with the current version. The tool isn’t truly “bulkified” so managing many many records will be problematic. There are also some limits on the number of “criteria diamonds” you can have and the number of active processes per object.

Differences between Process Builder and other tools in force.com

Salesforce offers various tools to automate business processes, for example, Flow, Workflow Rule, and Process Builder. So, it is required to understand the difference between these tools and when to use which. The following table describes the difference between these tools:
 
Workflow
Flow
Process Builder
Visual designer
Not available
Available
Available
Starts when
A record is created or edited
  • The user clicks on a custom button/link
  • A Process starts
  • Apex is called
  • Inline Visualforce page
  • The user accesses a custom tab
A record is created or edited
Supports time-based actions?
Yes
Yes
Supported, but only one scheduled-actions per criteria. This means that in the same Process..

Tuesday, 24 January 2017

Schema.DescribeSObjectResult in Apex and its usage in visualforce.

Schema.DescribeSObjectResult in Apex and its usage in visualforce.


This Describes SObject methods returns an array of DecribeSobjectResult objects. Where each object has the following properties.

String Name : This is the name of the object.

String Label :  Label text for the tab or an objct.

String LabelPlural : Label text for an object that represents plural version of object name.

String keyPrefix :  Object id's are prefixed with 3 character quotes that specify the type of the object.

Ex: - Account obj as 001, Opportunity object has 006.

When we call the keyPrefix it will return 3 character prefix code for the object which we are called.


Field[] fields: This will return array of the fields associated with an object.

Boolean Custom: Indicated whether the object is a custom object or not.

Boolean Creatable: Indicates whether the object can be created via created method.

Boolean deletable: Indicates whether the object can be deleted or not.

Boolean Mergable: Indicates whether the object can be merged with objects of its type.

Replicatable: Indicates whether the object can be replicatable via getUpdate function or getDeleted.

Boolean Retrievable : Indicates whether the object can be retrieved using retrieve method or not.

Boolean Searchable:- Indicates whether object can be searched via Search method .


Boolean updatable : Checks whether the object can be updatable or not.

To fetch the properties of an object

Schema.DescribeSobjectResult resultObj = Account.SobjectType.getDescribe();

                                              Or
Schema.DescribeSobjectResult result =  Schema.SobjectType.Account();

Example:

Field Example:

 Public class FieldExample{

   public String result {get;set;}

  Public FieldExample() {

 Schema.DescribeSobjectResult resultObj =          Account.SobjectType.getDescribe();
 result = ' ' +resultObj ;

}

}

In the above program 'resultObj' cibtaubs description about the object Account. If you want to know the properties individually we can use.

String getLabel();
String getKeyPrefix();
String getLabelPlural(); etc...



Child Relationship methods for given Object:


List <Schema.ChilRelationship> getChildRelationShips(); 

If an sobject is a parent object we can access the child relationships as well as the child objects using ChildRelationShip object.  This method returns the list of child objects for the given Sobject.


List of Child Records:

Program to display the List of Child objects for a given object

EX:-
public class ChildRelationshipExample {

public List<SelectOption> options;

public List<SelectOption> getOptions(){
 return options;
}

public ChildRelationshipExample(){

options = new List<SelectOption>();
Schema.DescribeSobjectResult r = Account.SobjectType.getDescribe();
List<Schema.childRelationship> c = r.getChildRelationShips();

for(schema.childRelationship x:c){
 String name = ' '+x.getChildSObject();
 SelectOption op = new SelectOption(name,name);
 options.add(op);
}

}


}

VF Page:

<apex:page controller="ChildRelationshipExample">
  <apex:form >
   <apex:selectlist size="1">
     <apex:selectoptions value="{!options}"></apex:selectoptions>
   </apex:selectlist>
  </apex:form>
</apex:page>



Thursday, 19 January 2017

How To Create Dynamic Dependent Picklist Of Objects in Salesforce

Apex Code:

public class sample
{
    public String state {get;set;}
    public String city {get;set;}

    public List<SelectOption> getStates()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));       
        options.add(new SelectOption('TN','Tamil Nadu'));
        options.add(new SelectOption('KL','Kerala'));
        return options;
    }
   
    public List<SelectOption> getCities()
    {
        List<SelectOption> options = new List<SelectOption>();
        if(state == 'TN')
        {      
            options.add(new SelectOption('CHE','Chennai'));
            options.add(new SelectOption('CBE','Coimbatore'));
        }
        else if(state == 'KL')
        {      
            options.add(new SelectOption('COA','Coachin'));
            options.add(new SelectOption('MVL','Mavelikara'));
        }
        else
        {
            options.add(new SelectOption('None','--- None ---'));
        }     
        return options;
    }      
}


Visualforce page:

<apex:page controller="sample">
   
    <apex:form >
   
    <apex:pageBlock>
        <apex:pageBlockSection columns="2">
            <apex:pageblockSectionItem>
                <apex:outputLabel value="State"/>
            </apex:pageblockSectionItem>       
            <apex:pageblockSectionItem>               
                <apex:selectList size="1" value="{!state}">
                    <apex:selectOptions value="{!states}"/>
                    <apex:actionSupport event="onchange" reRender="a"/>
                </apex:selectList>               
            </apex:pageblockSectionItem>
            <apex:pageblockSectionItem>
                <apex:outputLabel value="City"/>
            </apex:pageblockSectionItem>           
            <apex:pageblockSectionItem>
                <apex:selectList size="1" value="{!city}" id="a">
                    <apex:selectOptions value="{!cities}"/>
                </apex:selectList>
            </apex:pageblockSectionItem>           
        </apex:pageBlockSection>       
    </apex:pageBlock>

    </apex:form>

</apex:page>