Monday 31 October 2016

Chatter Messenger Missing

As per the Spring '16 release notes, Chatter Messenger: Retiring in Spring ’17 and unavailable and no longer supported for new Salesforce organizations created after Spring '16.
What this means for you: 
                      Chatter Messenger isn’t available in Salesforce orgs created Spring ’16 or later. If you enabled Chatter Messenger before Spring ’16, it remains available in your Salesforce org. Salesforce will no longer support Chatter Messenger as of Spring ’17.

For existing organizations which have been created prior to Spring '16 see:

How do you enable Chatter Messenger?​

Why I can not see Chatter Messenger for my organization with all supported browsers?

Tuesday 18 October 2016

Salesforce Tips

Hide the Label in Visualforce page which has been Binded from Objects:


<apex:inputField value="{!test.Dollar_Value__c}" required="true"  label="" styleClass="dollor"/>  


How to make the Text area or Description Field in Visualforce page to avoid adjusting in size:

 

  <apex:inputTextArea id="desc" value="{!con.Description}" label="" style=" width:1100px; height:600px; resize: none; ">

Wednesday 5 October 2016

Create Trigger for Checkbox

Scenario:

Assume that you have field as Default( checkbox), If New Record Default  field equal to True update all old records equal to False.
Code:
trigger makenewcheckboxtodefault on Account (before insert) {
    list&lt;Account&gt; acc=[select id,Name,Default__c from Account];
       for(integer i =0; i&lt;acc.size();i++){
          if(acc[i].Default__c==true ){
              acc[i].Default__c=false;
           }
        }
 update acc;
}
 

Alternative method:

you can write this logic in Apex class and you can call Apex method name in a Trigger.
To readers:If you need any further assistance and if you find any mistakes  let me know
Thanks:)
Create Anything!!! Control Anything!!!
 


Thursday 18 August 2016

GEOLOCATION FOR ACCOUNTS,CONTACTS AND LEADS


DISPLAY ACCOUNTS,CONTACTS,LEADS BASED ON LOCATION
Introduction:
Locate any Salesforce record data Address, anywhere in the world. These searches could be anything from a view of all accounts, clustered by concentrations, to a small neighborhood search for local leads and prospects. Geolocation will locate it (based on either an address or coordinates) and present it to you on an interactive Google Map.

After completing this unit, you’ll be able to:
  • create the latitude and longitude fields for Accounts, Contacts, leads.
  • Find the latitude and longitude of a place.
  • Find the distance based on latitude and longitude.
    CREATE THE LATITUDE AND LONGITUDE  FIELDS FOR ACCOUNTS, CONTACTS, LEADS BY FOLLOWING TABLE.
    S.No
    OBJECT
    FIELD LABEL
        API
      NAME
    DATA
    TYPE
    DECIMAL
    PLACES
    RETURN
    TYPE
    ADVANCED
    FORMULA
    1
    ACCOUNT
    Billing Address Latitude
    Billing_Address_Latitude__c
    Formula
    4
    Number
    BillingLatitude
    2
    ACCOUNT
    Billing Address
    Longitude
    Billing_Address_Longitude__c
    Formula
    4
    Number
    BillingLongitude
    3
    ACCOUNT
    Billing Address
    Accuracy
    Billing_Address_Accuracy__c
    Formula
    0
    Text
    Text( BillingGeocodeAccuracy )
    4
    ACCOUNT
    Shipping Address Latitude
    Shipping_Address_Latitude__c
    Formula
    4
    Number
    ShippingLatitude
    5
    ACCOUNT
    Shipping Address Longitude
    Shipping_Address_Longitude__c
    Formula
    4
    Number
    ShippingLongitude
    6
    ACCOUNT
    Shipping Address Accuracy
    Shipping_Address_Accuracy__c
    Formula
    0
    Text
    Text( ShippingGeocodeAccuracy )
    7
    CONTACT
    Mailing Address Latitude
    Mailing_Address_Latitude__c
    Formula
    4
    Number
    MailingLatitude
    8
    CONTACT
    Mailing Address Longitude
    Mailing_Address_Longitude__c
    Formula
    0
    Number
    MailingLongitude
    9
    CONTACT
    Mailing Address Accuracy
    Mailing_Address_Accuracy__c
    Formula
    0
    Text
    Text( MailingGeocodeAccuracy )
    10
    LEADS
    Address Latitude
    Address_Latitude__c
    Formula
    4
    Number
    Latitude
    11
    LEADS
    Address Longitude
    Address_Longitude__c
    Formula
    4
    Number
    Longitude
    12
    LEADS
    Address Accuracy
    Address_Accuracy__c
    Formula
    0
    Text
    Text( GeocodeAccuracy )

  • SCREEN SHOT FOR ACCOUNT LATITUDE,LONGITUDE,ACCURACY

            
            

    Create same as like this for Contacts and leads.

     Add the fileds to your pagelayouts.

    That's it for the Address field on leads! Now the geocode information associated with Address is visible on lead records. Repeat the same steps to add geocode information to the page layouts for accounts and contacts. Accounts have two address fields, and there are three associated geocode information fields (latitude, longitude, and accuracy rating) for each address.

    GEOCODE FIELDS:

    Geocode information identifies a location using a latitude, a longitude, and an accuracy rating. Geocode fields are available for standard addresses on accounts, contacts, and leads in Salesforce. Geocode fields are not visible on records, but they can be viewed using the Salesforce API.
    Geocodes are added to records using Data.com technology. However, a Data.com license is not required to use this feature
    1.)Setup>> enter Clean Rules in the Quick Find box >> select Clean Rules.

    2.)Edit a geocode clean rule. There are four geocode clean rules available.

    3.)Review your clean rule settings.

    4.)Save the rule.

    5.)Activate the rule.

    6.)If Clean all records when this rule is activated or saved is selected, geocodes are automatically added to all existing records. New records automatically get geocodes when they’re saved. Existing geocode values are overwritten.

    7.)Repeat this process for the other geocode clean rules.

    8.)In Salesforce Classic, if you want to be able to check the clean status of the geocode clean rules, add the Clean This Record with Data.com related list to the page layout for accounts, contacts, and leads. (In Lightning Experience, this step isn’t necessary!)

    9.)Fill the address in account,contacts,lead and press clean in related list of Record Detail Page.
     
    10.) To Integrate the map in to your developer org.


    create visualforce page like this


    <apex:page controller="Mapintegrations" showHeader="true" sidebar="false">
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map-canvas { width:1000px;height:600px; }
    </style>
    <body>
        <div id="map-canvas"/>
        <script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
        <script>
        var map;
       
        function initialize() {
            var mapOptions = {
                center: new google.maps.LatLng(19.337962, 76.684570),
                zoom: 15
            };
            map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
            plotlocation();
            plotlocationcon();
            plotlocationlead();
        }
       
        function plotlocation() {
            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.Mapintegrations.findAll}',
                function(result, event){
                    if (event.status) {
                        for (var i=0; i<result.length; i++) {
                            var id = result[i].Id;
                            var name = result[i].Name;
                            var lat = result[i].Billing_Address_Latitude__c;
                            var lng = result[i].Billing_Address_Longitude__c;
                            var lati =result[i].Shipping_Address_Latitude__c;
                            var lngi =result[i].Shipping_Address_Latitude__c;
                            addMarker(id, name, lat, lng,lati,lngi);
                        }
                    } else {
                        alert(event.message);
                    }
                },
                {escape: true}
            );
        }   
       
            function plotlocationcon() {
            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.Mapintegrations.findcon}',
                function(result, event){
                    if (event.status) {
                        for (var i=0; i<result.length; i++) {
                            var conid = result[i].Id;
                            var conname = result[i].Name;
                            var conlat = result[i].Address_Latitude__c;
                            var conlng = result[i].Address_Longitude__c;
                            addMarker(conid, conname, conlat, conlng);
                        }
                    } else {
                        alert(event.message);
                    }
                },
                {escape: true}
            );
        }
       
       
            function plotlocationlead() {
            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.Mapintegrations.findlead}',
                function(result, event){
                    if (event.status) {
                        for (var i=0; i<result.length; i++) {
                            var leadid = result[i].Id;
                            var leadname = result[i].Name;
                            var leadlat = result[i].Address_Latitude__c;
                            var leadlng = result[i].Address_Longitude__c;
                            addMarker(leadid, leadname, leadlat, leadlng);
                        }
                    } else {
                        alert(event.message);
                    }
                },
                {escape: true}
            );
        }
       
           function addMarker(id,name,lat,lng,lati,lngi,conid,conname,conlat,conlng,leadlat,leadlng) {
            var marker = new google.maps.Marker({
                    position: new google.maps.LatLng(lat,lng,lati,lngi,conlat, conlng,leadlat, leadlng),
                    map: map,
                    title: name            
            });
            google.maps.event.addListener(marker, 'click', function(event) {
                window.top.location = '/' + id;
            });
        }
       
        google.maps.event.addDomListener(window, 'load', initialize);
       
        </script>
    </body>
    </apex:page>


    CLASS FOR MAP INTEGRATION AND PLOTTING:

    global with sharing class Mapintegrations {
        @RemoteAction
        global static List<Account> findAll() {
            return [SELECT Id,Name,Billing_Address_Latitude__c, Billing_Address_Longitude__c,Billing_Address_Accuracy__c FROM Account];
                }
        @RemoteAction
        global static List<Contact> findcon() {
            return [select Id,Name,Address_Latitude__c,Address_Longitude__c,Address_Accuracy__c FROM Contact];    
        }
        @RemoteAction
        global static List<Lead> findlead() {
           return [select Id,Name,Address_Latitude__c,Address_Longitude__c,Address_Accuracy__c FROM Lead];
     }}




    geo map.png