• Sivasankari Muthu
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 25
    Questions
  • 20
    Replies
Hi,
 How to send any file or document  attachment  through the web to Salesforce lead.


thanks
Hi,
<apex:pageBlockTable value="{!lstwrapper}" var="key" id="ptb">  
                     <apex:column HeaderValue="{!key.FF}" >
                     <apex:outputText value="{!key.data[key.FF]}" />
                     </apex:column>
 </apex:pageBlockTable>

HeaderValue are not display the table.Outputtext value not display in table format. full values are displayed in single column

Now I am getting the following result
User-added image
Thanks,
Hi All
 I have one detail Object like,
  
ObjectFields
AccountName
Accountid
AccountWebsite
contactname
contactMobile
Leadname
Leadsource

how to group by the fields using object.
I want to display the above sobject fields values into  single pageblock table in the vfp

thanks,
 
Hi All,

I have one custom ( vf page) button for generate quote in opportunity Detail Page. Click this button it generate a custom quote in pdf format.
 In my Scenario, I click that quote button I want to check whether the quote object “IsSyncing"  field is checked or not, If its not checked I want to display one alert for "sync Quote" I am using Professional Edition.
 
Hi All,
In my scenario,I have two objects Student_Academic and student_score,
Student_Academicobject contains :stuId,Name
User-added image
student_score Contains:stuId,Subject,Marks
User-added image
Page design is
User-added image
After click the save button the relevant marks and subject to that corresponding student store in student_score object

Thanks
Hi,
I am seraching the students by Student Name. 
Query: select Name,Student_Name__r.External_Student_Id__c, Year__c, School_Name__r.School_Name__c, Student_Name__r.Student_First_Name__c, Student_Name__r.Student_Last_Name__c from Student_Academic_Class__c where Student_Name__r.Student_First_Name__c =: student;
Need Student Name, School name from the above query without duplicate entry.
User-added image
Student Name: Test (Link)
It showing Student data based on Class Name count. In the above example Student link TEST have three class.
How to avoid duplicate entry of Student ?.


Thanks
Sivasankari M
Hi,
I am having Two visualforce pages:
First Page: DisplayUniversities.vfp
 
<apex:page Controller="ILP_College_District_City" showHeader="false" sidebar="false" standardStylesheets="True" docType="html-5.0">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" />
<apex:includeScript value="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js" />
<apex:stylesheet value="{!URLFOR($Resource.SLDS0120, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
<apex:stylesheet value="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
  <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">  
<apex:insert name="header">
<c:ILPCSMHEADER ></c:ILPCSMHEADER>
</apex:insert>
    <apex:form>
        <style>
        .center {
    	text-align: center;}
        </style>
        <br/>
        <br/>
        
    <table>
    <tr>
    	<td ><apex:inputText list="{!listOfDistrictName}" value="{!district}" html-placeholder="Enter District Name" /></td> 
        <td ><apex:inputText list="{!listOfCityName}" value="{!city}" html-placeholder="Enter City Name" /></td> 
    	<td ><apex:commandButton value="Go!" action="{!search_method}"/></td>
    </tr>
        </table>
    <!--</table>
        <table>
            <tr>
            <th>College Name</th>
            </tr>
        </table>
        <apex:repeat value="{!districts}" var="dis">
            <div class="center">
                <td>{!dis.College_Name__c}</td><br/>
            </div>
        </apex:repeat>-->
        
        <apex:pageBlock >
    <apex:pageBlockSection >
    <apex:pageBlockTable value="{!districts}" var="dis">
        <apex:column >
        <apex:facet name="header">College Name</apex:facet>
            <!--<apex:outputField value="{!dis.College_Name__c}"/>-->
            <apex:commandLink action="{!Move}" >{!dis.College_Name__c}
            <apex:param name="collegeId" value="{!dis.id}" assignTo="{!collegeId}"/>
            </apex:commandLink>
        </apex:column>
        </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
              
    </html>
</apex:page>
The Output of first page:

User-added image

Controller : ILP_College_District_City
 
public class ILP_College_District_City {
ID qstr = System.currentPagereference().getParameters().get('collegeId');
public List<String> listOfDistrictName {get;set;}
public List<String> listOfCityName {get;set;}
public List<ILP_CSM_COLLEGES__c> districts {get;set;}  
public List<ILP_CSM_COLLEGES__c> cities{get;set;}
public List<ILP_CSM_COURSES_BY_COLLEGES__c> colleges{get;set;}
//public ILP_CSM_COURSES_BY_COLLEGES__c collegess;
public string district{get;set;}
public string city{get;set;}
public string collegeId{get;set;}
    public ILP_College_District_City()
    {
        listOfDistrictName = new List<String>();   
	for(ILP_CSM_COLLEGES__c districtName: [select id,District__c from ILP_CSM_COLLEGES__c ])
		listOfDistrictName.add(districtName.District__c);
        listOfCityName = new List<String>();   
	for(ILP_CSM_COLLEGES__c districtName: [select id,City_Town__c from ILP_CSM_COLLEGES__c ])
		listOfCityName.add(districtName.City_Town__c);
    }
    public LIST<ILP_CSM_COURSES_BY_COLLEGES__c> getColleges()
    {
        System.debug('qstr'+qstr);
       colleges = [Select Name, Course_Level__c, Degree_Conferred__c,College_UGC_Id__r.College_Name__c from ILP_CSM_COURSES_BY_COLLEGES__c where College_UGC_Id__c =: qstr];
    return colleges;
    }
    public void search_method()
    {
        //students = [select Student_First_Name__c, Student_Last_Name__c from ILP_CSM_Student_Profile__c where Student_First_Name__c =: student];
         if(!district.equals(''))
        	districts = [select College_Name__c from ILP_CSM_COLLEGES__c where District__c =: district];
        	
    	 if(!city.equals(''))
            //schools = [select id, Name,School_Name__c, Village_Name__c,District__c, State__c from Schools_Master__c where School_Name__c =: school];
    		districts = [select College_Name__c from ILP_CSM_COLLEGES__c where City_Town__c =: city];
    	
    }
    public PageReference Move()
    {
        String qstr = System.currentPagereference().getParameters().get('collegeId');
        System.debug('move'+qstr);
    //PageReference Page = new PageReference('/apex/StudentAcadpgTest?id='+qstr1);
    PageReference Page = new PageReference('/apex/ILP_College?id='+qstr);
    //colleges = [Select Name, Course_Level__c, Degree_Conferred__c,College_UGC_Id__r.College_Name__c from ILP_CSM_COURSES_BY_COLLEGES__c where College_UGC_Id__c =: qstr];
    Page.setRedirect(true);
    return Page;
    }
}
Once i click on the College name, It will redirect to second page with college id.
Second Page: ILP_College.vfp
This page is also using the same above controller. This page use the college id what in URL to show the data of that college. But this id is not entering into method (getColleges()) to query the college details.
<apex:page Controller="ILP_College_District_City" showHeader="false" sidebar="false" standardStylesheets="True" docType="html-5.0">
   <apex:form>
    <apex:pageBlock >
    <apex:pageBlockSection >
    <apex:pageBlockTable value="{!colleges}" var="dis">
        <apex:column >
        <apex:facet name="header">College Name</apex:facet>
            <apex:outputField value="{!dis.Name}"/>
            <apex:outputField value="{!dis.Course_Level__c}"/>
            <apex:outputField value="{!dis.Degree_Conferred__c}"/>
            <apex:outputField value="{!dis.College_UGC_Id__r.College_Name__c}"/>
        </apex:column>
        </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form> 
</apex:page>
Output of second page:

User-added image

This second page is not showing the data from controller.

Please suggest solution.

Thanks
Sankari M
Hi,

Scenario: To get all student data from a single school. (Eg: ABC ( School) has 50 students. PDF --> Every student has one page , so totally 50 pages in single PDF)
Tables: 1. School_Name   2. Student_Profile   3. Students_Academics   4. Student_Family_Details   5. Counselling_Parameters
LookUps: 1. In Students_Academics, lookup(School_Name,  Student_Profile)   2.  In Student_Family_Details   lookup(Student_Profile)    3. In Counselling_Parameters lookup(Student_Profile)
Related List: 1. Student_Profile --> Students_Academics  ,Student_Family_Details,Counselling_Parameters
                     2.School_Name --> Students_Academics
Questions:
By passing School as a input How to get entire students of that school in single PDF? (PDF contains above 4 Table data for every students)

Can anyone please tell me how to solve it?

Thanks,
Sivasankari M
                
Hi All,
In my scenario ,
Select page(input)-select industry and product
User-added image

Select page-click image
User-added image

Detail page- it shows relevant information about the image
User-added image

but in my case the detail page could not shows any informations.it couldn't receive any input from previous page(Select page).
My Code is:
Vfp-1(select page)
 
<apex:commandLink target="_blank" action="{!hello1}">
<apex:image value="{!account.photo__c}" height="150" width="200" id="test"   /> 
    
    </apex:commandLink>


My Controller page:
public PageReference  hello1(){
       PageReference pagr= new PageReference('/apex/custrefdetail');   
String searchStr1=ApexPages.currentPage().getParameters().get('searchStr'); //input - industry
     String productName1=ApexPages.currentPage().getParameters().get('productName');//input - product

accprd = [SELECT Detail__c,Product__c from  accproducts__c where Product__c =:productName1  and account__c in (select ID from Account where industry=:searchStr1)];
      System.debug(productName1);//product
      System.debug(searchStr1);//industry
              pagr.setRedirect(false); 
             return pagr;
	}
product and industry values shows as null. I dont know how to pass the detail value in visualforce page2.

if anybody knows please tell me.

Thanks,
M. Sivasankari.



 
Hi all,
I have two visualforce page and one controller in my scenario,
First page I give two input industry and product,its given the result certain group of company picture in href link.If I click one image it gives some relevent detail about the company its like  https://www.salesforce.com/customers/.


VFP-1
<apex:page sidebar="false" showheader="false" controller="sfdctest" tabStyle="account">
<apex:form >
<apex:pageMessages id="pId"/>
    <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Select a Industry & Product" >
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:selectList value="{!searchStr}" size="1"> 
                    <apex:selectOptions value="{!Industrynames}" />
          </apex:selectList>    
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <apex:selectList size="1" value="{!productName}">
            <apex:selectOptions value="{!items}"/>
    </apex:selectList> 
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <apex:outputPanel id="myRerender">

         <apex:commandButton value="Submit" action="{!soslDemo_method}"  ReRender="pgId,pId"  />
            </apex:outputPanel>

      </apex:pageBlock>
    
    <apex:pageBlock title="Customer details" id="pgId">
        
       <apex:repeat value="{!acc}" var="account">
     
             
<style>
    body {margin:50px;}
   
div.img {

    -webkit-align-items: baseline;
    align-items:baseline;
     margin: 10px;
    border: 1px solid #ccc;
    float: left;
    width: 220px;
   
    margin-bottom:25px;
    box:0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}    
  div.img:hover {
    
    border: 1px solid #777;
   
}

div.img img {
    max-width:100%;
    width: 100%;
    height: 150px;
    
}

    
div.desc {
    font-family:"arial";
    background-color : lightgrey;
    padding: 10px 20px;
   
    height: 50px;
    text-align: justify;
}   
 
    
   </style>      
 <body>
     

<div class="img" >

    <apex:outputLink target="_blank" value="{!$Page.custrefdetail}" id="tst" >   <!--   custrefdetail it is my second vfp -->
            <apex:image value="{!account.photo__c}" height="150" width="200"   /> 
        

            
     </apex:outputLink> 
    <div class="desc"><h1>
    
        {!account.Name}
        </h1>
        <p>
        {!account.Description}
        </p>
        </div>
   
</div>
    
     </body>
        </apex:repeat>
    </apex:pageBlock>
</apex:form>
</apex:page>
 
VFP: 2
<apex:page sidebar="false" showHeader="false" controller="sfdctest" action="{!hello1}" >
<apex:form >
  <apex:pageBlock >
    <apex:repeat value="{!accprd}" var="accs">
      <p>
     {!accs.Detail__c}
        </p>   

   </apex:repeat>  
        </apex:pageBlock>
     </apex:form>
  
</apex:page>

Controller

Public with sharing class sfdctest{
 Public List<Account> acc{get;set;} 
 Public List<accproducts__c> accprd{get;set;}
     public ApexPages.StandardSetController setController { get; set;}    
 public String imageURL{get;set;}
 Public String searchStr{get;set;} 
 public string productName{get;set;}

  public Void hello1(){
    accprd = New List<accproducts__c>(); 
     accprd = [SELECT Detail__c from  accproducts__c where Product__r.name =:productName  and account__c in (select ID from Account where industry=:searchStr)];
System.debug(productName);
   }

public List<selectoption> getIndustrynames()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
     options.add(new SelectOption('select','Select Industry'));     
    for (Schema.PicklistEntry a : values) 
    {                  
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options; 
}


public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('selectprd','Select Product')); 
    for(product2 c : [select ID, name  from product2  where ID IN( select Product__c from accproducts__c )]){
        options.add(new SelectOption(c.ID, c.name));
    }  
    return options;
}
    
 public  sfdctest()
  {
    acc = New List<Account>();
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
     
  Public void soslDemo_method(){
      System.debug(searchStr);
   if(searchStr.length() > 1 && searchStr != 'select'){
       acc = [SELECT Name,image__c,photo__c,Description,website from Account  where industry=:searchStr and Id in (select account__c from accproducts__c where Product__c = :productName )  ];
        System.debug('product');
       if(acc.size() == 0) {
           apexPages.addmessage(new apexpages.message(apexpages.severity.WARNING, 'Sorry, data not found'));
            return;
          }
       }

   else{
       acc = [SELECT Name,image__c,photo__c,Description,website from Account  where Id in (select account__c from accproducts__c )  ];
      
   }
  }
   }

 I try to display the hello1 method detail__c value  in my vfp2.


Thanks,
M. Sivasankari.
Hi,
Pls find out the error ,I found that the error related to "recordsetvar".
My code display the current location and the nearby location of Loc__c (Custom Object) address.
ERROR: common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType

My codes:
Apex Codes,
// https://blog.ticmind.es/2014/10/17/codigo-apex-y-visualforce-de-findnearby/
global with sharing class VicinageFindNearby {
    public VicinageFindNearby(ApexPages.StandardController controller) {}
 
    @RemoteAction
    // Find Accounts nearest a geolocation
    global static List<Loc__c> getNearby(String lat, String lon) {
        // If geolocation is not set, use Plaza Santa Bárbara, 2, Madrid
        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '40.427305';
            lon = '3.696754';
        }
 
        // SOQL query to get the nearest warehouses
        String queryString =
            'SELECT Id, Name, Map__Longitude__s, Map__Latitude__s,State_Province__c,City__c,Zip_Code__c ' +
            'FROM Loc__c '+
            'WHERE DISTANCE(Map__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 20 ' +
            'ORDER BY DISTANCE(Map__c, GEOLOCATION('+lat+','+lon+'), \'km\') ' +
            'LIMIT 25';
 
        // Run and return the query results
        return(database.Query(queryString));
    }
}

VFP:
<apex:page sidebar="false" showheader="false" standardController="Loc__c" recordSetVar="loc"  extensions="VicinageFindNearby">
    
    <!-- Include in Google's Maps API via JavaScript static resource -->
    <apex:includeScript value="{!$Resource.googleMapsAPI}" /> 
    
    <!-- Set this API key to fix JavaScript errors in production -->
    <!--http://salesforcesolutions.blogspot.com/2013/01/integration-of-salesforcecom-and-google.html-->
    <script type="text/javascript" 
        src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCROH4OR9fzDhmprWPL1wGWfPT4uGUeMWg&sensor=false"> 
        </script>
        
    <!-- Setup the map to take up the whole window --> 
    <style>
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
    </style>
    
    <script>
        function initialize() {
            var lat, lon,accts;
              
             // If we can, get the position of the user via device geolocation
             if (navigator.geolocation) {
                 navigator.geolocation.getCurrentPosition(function(position){
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     
                     // Use Visualforce JavaScript Remoting to query for nearby accts      
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.VicinageFindNearby.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 console.log(result);
                                 createMap(lat, lon, result);           
                             } else if (event.type === 'exception') {
                                 //exception case code          
                             } else {
                                            
                             }
                          }, 
                          {escape: true}
                      );
                  });
              } else {
                  // Set default values for map if the device doesn't have geolocation capabilities
                    /** Eindhoven **/
                    lat = 51.096214;
                    lon = 3.683153;
                    
                    var result = [];
                    createMap(lat, lon, result);
              }
          
         }
    
         function createMap(lat,lon,accts){
            // Get the map div, and center the map at the proper geolocation
            var currentPosition = new google.maps.LatLng(lat,lon);
            var mapDiv = document.getElementById('map-canvas');
            var map = new google.maps.Map(mapDiv, {
                center: currentPosition, 
                zoom: 13,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });
            
            // Set a marker for the current location
            var positionMarker = new google.maps.Marker({
                map: map,
                position: currentPosition,
                icon: 'http://maps.google.com/mapfiles/ms/micons/green.png'
            });
            
                        
            // Keep track of the map boundary that holds all markers
            var mapBoundary = new google.maps.LatLngBounds();
            mapBoundary.extend(currentPosition);
            
            // Set markers on the map from the @RemoteAction results
            var acct;
            for(var i=0; i<accts.length;i++){
                acct = accts[i];
                console.log(accts[i]);
                setupMarker();
            }
            
            // Resize map to neatly fit all of the markers
            map.fitBounds(mapBoundary);

           function setupMarker(){ 
                var acctNavUrl;
                
                // Determine if we are in Salesforce1 and set navigation link appropriately
                try{
                    if(sforce.one){
                        acctNavUrl = 
                            'javascript:sforce.one.navigateToSObject(\'' + acct.Id + '\')';
                    }
                } catch(err) {
                    console.log(err);
                    acctNavUrl = '\\' + acct.Id;
                }
                
                var acctDetails = 
                    '<a href="' + acctNavUrl + '">' + 
                    acct.Name + '</a><br/>' + 
                    acct.City__c + '<br/>' + 
                    acct.Country__c + '<br/>' + 
                    acct.Zip_Code__c;
               
               // Create the callout that will pop up on the marker     
               var infowindow = new google.maps.InfoWindow({ 
                   content: acctDetails
               });
               
               // Place the marker on the map   
               var marker = new google.maps.Marker({
                   map: map,
                   position: new google.maps.LatLng( 
                                   acct.Map__Latitude__s, 
                                   acct.Map__Longitude__s)
               });
               mapBoundary.extend(marker.getPosition());
               
               // Add the action to open up the panel when it's marker is clicked      
               google.maps.event.addListener(marker, 'click', function(){
                   infowindow.open(map, marker);
               });
           }
        }
        
        // Fire the initialize function when the window loads
        google.maps.event.addDomListener(window, 'load', initialize);
        
    </script>
    
    
    <body style="font-family: Arial; border: 0 none;">
       
   <!--  All content is rendered by the Google Maps code -->
    <!--  This minimal HTML justs provide a target for GMaps to write to -->
        <div id="map-canvas"></div>
    </body>
</apex:page>

Thanks
Sivasankari.M
Hi EveryOne,
 how to write a soql query 
I have two picklist. 
one is industry picklist- Account (standard Object)
another one is product(Product__c) picklist -  accproducts__c (custom object)
I want to pass these two picklist as a input to get a record .

I attached the screenshot of my scenario .Please view it and  help me.
User-added image
In Expected Result : 
Account Id ,Industry & Account name - Account (Standard object)
Product name - accproduct__c (Custom Object)


Thanks,
​M. Sivasankari
 
Hi Everyone,
 how to write a soql query 
we have two picklist. 
one is industry picklist-standard controller Account
another one is product(Product__c) picklist - custom object accproducts__c.
I want to pass these two picklist as a input to get a record 

I tried and doesn't work the query
select a.Name,a.ID,ap.Product__c from account a,accproducts__c ap where a.id=ap.account__c and ap.Product__r.name='GenWatt Propane 1500kW' and a.industry='banking'


error:Unknown error parsing query


Thanks,
​M. Sivasankari
 
Hi Everyone,
I have problem in soql query,
select a.Name,a.ID,ap.Product__c from account a,accproducts__c ap
where a.id=ap.account__c and ap.Product__r.name='GenWatt Propane 1500kW'  and a.industry='banking';
error:Unknown error parsing query

Standard object:Account
Custom Object :accproducts__c

if anybody knows the solution please tell me.

Thanks & Regard,
M. Sivasankari
Hi Everyone,

I want to get google map for current location viewing  & longitude and latitude without api key.

google javascript api v3  js file Link
https://maps.googleapis.com/maps/api/js

Codes:

1.VF Code:
<apex:page sidebar="false" showheader="false" standardController="Account"  extensions="FindNearby">
    
    <!-- Include in Google's Maps API via JavaScript static resource -->
    <apex:includeScript value="{!$Resource.googleMapsAPI}" /> 
    
    <!-- Set this API key to fix JavaScript errors in production -->
    <!--http://salesforcesolutions.blogspot.com/2013/01/integration-of-salesforcecom-and-google.html-->
    <script type="text/javascript" 
       src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> <!-- We try to get google mapy without API Key (Javascript V3) but i did not show the current location as well as longitude and latitude -->
<!-- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAowmYdY3dZwoe4qI1I_X8Ry-UPepb5dpA&sensor=false">   previously we used API key to generate Google Map but  the usage of API key is very limited(Only 4 times)  -->

        </script>
        
    <!-- Setup the map to take up the whole window --> 
    <style>
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
    </style>
    
    <script>
        function initialize() {
            var lat, lon;
              
             // If we can, get the position of the user via device geolocation
             if (navigator.geolocation) {
                 navigator.geolocation.getCurrentPosition(function(position){
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     
                     // Use Visualforce JavaScript Remoting to query for nearby accts      
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.FindNearby.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 console.log(result);
                                 createMap(lat, lon, result);           
                             } else if (event.type === 'exception') {
                                 //exception case code          
                             } else {
                                            
                             }
                          }, 
                          {escape: true}
                      );
                  });
              } else {
                  // Set default values for map if the device doesn't have geolocation capabilities
                    /** Eindhoven **/
                    lat = 12.9172;
                    lon = 80.1929;
                    
                    var result = [];
                    createMap(lat, lon, result);
              }
          
         }
    
         function createMap(lat, lon, accts)
    {
            // Get the map div, and center the map at the proper geolocation
            var currentPosition = new google.maps.LatLng(lat,lon);
            var mapDiv = document.getElementById('map-canvas');
            var map = new google.maps.Map(mapDiv, {
                center: currentPosition, 
                zoom: 13,
                mapTypeId: google.maps.MapTypeId.ROADTYPE
            });
           
            // Set a marker for the current location
            var positionMarker = new google.maps.Marker({
                map: map,
                position: currentPosition,
                icon: 'http://maps.google.com/mapfiles/ms/micons/pink.png'
            });
            
                        
            // Keep track of the map boundary that holds all markers
            var mapBoundary = new google.maps.LatLngBounds();
            mapBoundary.extend(currentPosition);
            
            // Set markers on the map from the @RemoteAction results
            var acct;
            for(var i=0; i<accts.length;i++){
                acct = accts[i];
                console.log(accts[i]);
                setupMarker();
            }
            
            // Resize map to neatly fit all of the markers
            map.fitBounds(mapBoundary);

           function setupMarker(){ 
                var acctNavUrl;
                
                // Determine if we are in Salesforce1 and set navigation link appropriately
                try{
                    if(sforce.one){
                        acctNavUrl = 
                            'javascript:sforce.one.navigateToSObject(\'' + acct.Id + '\')';
                    }
                } catch(err) {
                    console.log(err);
                    acctNavUrl = '\\' + acct.Id;
                }
                
                var acctDetails = 
                    '<a href="' + acctNavUrl + '">' + 
                    acct.Name + '</a><br/>' + 
                    acct.BillingStreet + '<br/>' + 
                    acct.BillingCity + '<br/>' + 
                    acct.Phone;
               
               // Create the callout that will pop up on the marker     
               var infowindow = new google.maps.InfoWindow({ 
                   content: acctDetails
               });
               
               // Place the marker on the map   
               var marker = new google.maps.Marker({
                   map: map,
                   position: new google.maps.LatLng( 
                                   acct.Location__Latitude__s, 
                                   acct.Location__Longitude__s)
               });
               mapBoundary.extend(marker.getPosition());
               
               // Add the action to open up the panel when it's marker is clicked      
               google.maps.event.addListener(marker, 'click', function(){
                   infowindow.open(map, marker);
               });
           }
        }
        
        // Fire the initialize function when the window loads
        google.maps.event.addDomListener(window, 'load', initialize);
        
    </script>
    
    
    <body style="font-family: Arial; border: 0 none;">
       
   <!--  All content is rendered by the Google Maps code -->
    <!--  This minimal HTML justs provide a target for GMaps to write to -->
        <div id="map-canvas"></div>
    </body>
</apex:page>

2.Apex Class --- FindNearby
global with sharing class FindNearby {

   public FindNearby(ApexPages.StandardController sc){} 
    
    @RemoteAction
    // Find Accounts nearest a geolocation
    global static List<Account> getNearby(String lat, String lon) {

        // If geolocation isn't set, use Eindhoven (or any other city)
        // Put a default location latitue and longitude here, this could be where you are located the most
        // and will only be used as a backup if the browser can not get your location details
        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '51.096214';
            lon = '3.683153';
        }

        // SOQL query to get the nearest accounts
        //you can change km (kilometers) into mi (miles)
        // < 20 means within a radius of 20 km or mi (you can change that)
        //limit 25 shows 25 records (you can adapt that too if you want)
        String queryString =
            'SELECT Id, Name, Location__Longitude__s, Location__Latitude__s, ' +
                'BillingStreet, Phone, BillingCity ' +
            'FROM Account ' +
            'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 20 ' +
            'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') ' +
            'LIMIT 25';

        // Run and return the query results
        return(database.Query(queryString));
    }
}

3.Apex Trigger
// Trigger runs getLocation() on Accounts with no Geolocation
trigger SetGeolocation on Account (after insert, after update) {
    for (Account a : trigger.new){
        if(Trigger.isUpdate){
            if(a.BillingStreet != Trigger.oldMap.get(a.id).BillingStreet || a.BillingCity != Trigger.oldMap.get(a.id).BillingCity || a.BillingPostalCode != Trigger.oldMap.get(a.id).BillingPostalCode){
                LocationCallouts.getLocation(a.id);
            }
        }
        if (a.Location__Latitude__s == null)
            LocationCallouts.getLocation(a.id);
}
}

4.Apex Class

public class LocationCallouts {
 
     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setMethod('GET');
        req.setTimeout(6000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug(res.getBody());
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.Location__Latitude__s = lat;
                a.Location__Longitude__s = lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}

Thanks in advance,
If anybody know please tell me.

Thanks and Regards,
Sivasankari.M
Hi Everyone,

I want to get google map for current location viewing  & longitude and latitude without api key.

google javascript api v3  js file Link
https://maps.googleapis.com/maps/api/js

Codes:

1.VF Code:
<apex:page sidebar="false" showheader="false" standardController="Account"  extensions="FindNearby">
    
    <!-- Include in Google's Maps API via JavaScript static resource -->
    <apex:includeScript value="{!$Resource.googleMapsAPI}" /> 
    
    <!-- Set this API key to fix JavaScript errors in production -->
    <!--http://salesforcesolutions.blogspot.com/2013/01/integration-of-salesforcecom-and-google.html-->
    <script type="text/javascript" 
       src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> <!-- We try to get google mapy without API Key (Javascript V3) but i did not show the current location as well as longitude and latitude -->
<!-- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAowmYdY3dZwoe4qI1I_X8Ry-UPepb5dpA&sensor=false">    previously we used API key to generate Google Map but  the usage of API key is very limited(Only 4 times)  -->

        </script>
        
    <!-- Setup the map to take up the whole window --> 
    <style>
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
    </style>
    
    <script>
        function initialize() {
            var lat, lon;
              
             // If we can, get the position of the user via device geolocation
             if (navigator.geolocation) {
                 navigator.geolocation.getCurrentPosition(function(position){
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     
                     // Use Visualforce JavaScript Remoting to query for nearby accts      
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.FindNearby.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 console.log(result);
                                 createMap(lat, lon, result);           
                             } else if (event.type === 'exception') {
                                 //exception case code          
                             } else {
                                            
                             }
                          }, 
                          {escape: true}
                      );
                  });
              } else {
                  // Set default values for map if the device doesn't have geolocation capabilities
                    /** Eindhoven **/
                    lat = 12.9172;
                    lon = 80.1929;
                    
                    var result = [];
                    createMap(lat, lon, result);
              }
          
         }
    
         function createMap(lat, lon, accts)
    {
            // Get the map div, and center the map at the proper geolocation
            var currentPosition = new google.maps.LatLng(lat,lon);
            var mapDiv = document.getElementById('map-canvas');
            var map = new google.maps.Map(mapDiv, {
                center: currentPosition, 
                zoom: 13,
                mapTypeId: google.maps.MapTypeId.ROADTYPE
            });
           
            // Set a marker for the current location
            var positionMarker = new google.maps.Marker({
                map: map,
                position: currentPosition,
                icon: 'http://maps.google.com/mapfiles/ms/micons/pink.png'
            });
            
                        
            // Keep track of the map boundary that holds all markers
            var mapBoundary = new google.maps.LatLngBounds();
            mapBoundary.extend(currentPosition);
            
            // Set markers on the map from the @RemoteAction results
            var acct;
            for(var i=0; i<accts.length;i++){
                acct = accts[i];
                console.log(accts[i]);
                setupMarker();
            }
            
            // Resize map to neatly fit all of the markers
            map.fitBounds(mapBoundary);

           function setupMarker(){ 
                var acctNavUrl;
                
                // Determine if we are in Salesforce1 and set navigation link appropriately
                try{
                    if(sforce.one){
                        acctNavUrl = 
                            'javascript:sforce.one.navigateToSObject(\'' + acct.Id + '\')';
                    }
                } catch(err) {
                    console.log(err);
                    acctNavUrl = '\\' + acct.Id;
                }
                
                var acctDetails = 
                    '<a href="' + acctNavUrl + '">' + 
                    acct.Name + '</a><br/>' + 
                    acct.BillingStreet + '<br/>' + 
                    acct.BillingCity + '<br/>' + 
                    acct.Phone;
               
               // Create the callout that will pop up on the marker     
               var infowindow = new google.maps.InfoWindow({ 
                   content: acctDetails
               });
               
               // Place the marker on the map   
               var marker = new google.maps.Marker({
                   map: map,
                   position: new google.maps.LatLng( 
                                   acct.Location__Latitude__s, 
                                   acct.Location__Longitude__s)
               });
               mapBoundary.extend(marker.getPosition());
               
               // Add the action to open up the panel when it's marker is clicked      
               google.maps.event.addListener(marker, 'click', function(){
                   infowindow.open(map, marker);
               });
           }
        }
        
        // Fire the initialize function when the window loads
        google.maps.event.addDomListener(window, 'load', initialize);
        
    </script>
    
    
    <body style="font-family: Arial; border: 0 none;">
       
   <!--  All content is rendered by the Google Maps code -->
    <!--  This minimal HTML justs provide a target for GMaps to write to -->
        <div id="map-canvas"></div>
    </body>
</apex:page>

2.Apex Class --- FindNearby
global with sharing class FindNearby {

   public FindNearby(ApexPages.StandardController sc){} 
    
    @RemoteAction
    // Find Accounts nearest a geolocation
    global static List<Account> getNearby(String lat, String lon) {

        // If geolocation isn't set, use Eindhoven (or any other city)
        // Put a default location latitue and longitude here, this could be where you are located the most
        // and will only be used as a backup if the browser can not get your location details
        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '51.096214';
            lon = '3.683153';
        }

        // SOQL query to get the nearest accounts
        //you can change km (kilometers) into mi (miles)
        // < 20 means within a radius of 20 km or mi (you can change that)
        //limit 25 shows 25 records (you can adapt that too if you want)
        String queryString =
            'SELECT Id, Name, Location__Longitude__s, Location__Latitude__s, ' +
                'BillingStreet, Phone, BillingCity ' +
            'FROM Account ' +
            'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 20 ' +
            'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') ' +
            'LIMIT 25';

        // Run and return the query results
        return(database.Query(queryString));
    }
}

3.Apex Trigger
// Trigger runs getLocation() on Accounts with no Geolocation
trigger SetGeolocation on Account (after insert, after update) {
    for (Account a : trigger.new){
        if(Trigger.isUpdate){
            if(a.BillingStreet != Trigger.oldMap.get(a.id).BillingStreet || a.BillingCity != Trigger.oldMap.get(a.id).BillingCity || a.BillingPostalCode != Trigger.oldMap.get(a.id).BillingPostalCode){
                LocationCallouts.getLocation(a.id);
            }
        }
        if (a.Location__Latitude__s == null)
            LocationCallouts.getLocation(a.id);
}
}

4.Apex Class

public class LocationCallouts {
 
     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setMethod('GET');
        req.setTimeout(6000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug(res.getBody());
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.Location__Latitude__s = lat;
                a.Location__Longitude__s = lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}

Thanks in advance,
If anybody know please tell me.

Thanks and Regards,
Sivasankari.M
Hi,
My scenario is,
I have to get the details by location(State or Country).1st preference is State.
My output will be,
User-added image
The input fields are Standard Country and State picklist .
The state or country (input) has  pass to the apex controller.
[ Eg:
1.country :USA State: NY---- input will be NY(State)
 2. country:Iceland  State : No States ,------ input will be  Iceland(Country) 
]
I dont know how to pass theat selected state picklist value to apex controller.

But i written some piece of codes.Please verify it and correct it. If anyone knows please tell me.

My Apex Code:

Public with sharing class SOSLController{
 Public List<loc__c> location {get;set;} // location
    public String imageURL{get;set;} // display a image
 Public String searchStr{get;set;} // find a string
 private ApexPages.StandardController stdController;
  /* display a image -method*/
 public  SOSLController(ApexPages.StandardController stdController)
  {
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where 
                                    Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
    /* find a string and  run the sosl query*/
  Public void soslDemo_method(){
   location = New List<loc__c>();
   if(searchStr.length() > 1){
   String searchStr1 = searchStr;
     //  System.debug('message');
       String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  loc__c(Comp__c, Type__c,Client__c, Competitor__c,Event_Name__c, evt_Des__c , Et_Addr__c, Dt_Ti__c, Ct_person__c,Ph_Num__c )';
   List<List <sObject>> searchList = search.query(searchQuery);
   location = ((List<loc__c>)searchList[0]);
       /* Message */
   if(location.size() == 0){
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, Type the location correctly or There is no details of the requested location found'));
       return;
   }}
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter the location..'));
   return;
   }}}

My VFP:

<apex:page standardController="Contact"  extensions="SOSLController"  sidebar="false" showHeader="false">
  <apex:form >
       <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Enter a location" id="acct1">
          <apex:outputLabel value="Country" />
          <apex:inputField value="{!contact.MailingCountryCode}" />
            <apex:outputLabel value="State" />
          <apex:inputField value="{!contact.MailingStateCode}" />
    <apex:commandButton value="Submit" action="{!soslDemo_method}"  reRender="acct,error,acct1" />
    <apex:outputPanel title="" id="error">
     <apex:pageMessages ></apex:pageMessages>
     </apex:outputPanel>
  </apex:pageBlock>
    <apex:pageBlock title="Details of technical events" id="acct">
    <apex:pageblockTable value="{!location }" var="acc">
           <apex:column value="{!acc.Comp__c}"/>
         <apex:column value="{!acc.Type__c}"/>
          <apex:column value="{!acc.Client__c}"/>
        <apex:column value="{!acc.Competitor__c}"/>
        <apex:column value="{!acc.Event_Name__c}"/>
          <apex:column value="{!acc.evt_Des__c}"/>
        <apex:column value="{!acc.Et_Addr__c}"/>
          <apex:column value="{!acc.Dt_Ti__c}"/>
        <apex:column value="{!acc.Ct_Person__c}"/>
          <apex:column value="{!acc.Ph_Num__c}"/>
       </apex:pageblockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>


Thanks and Regards,
Sivasankari.M
Hi,
My scenario is,
I have to get the details by location(State or Country).1st preference is State.
My output will be,
User-added image
The input fields are Standard Country and State picklist .
The state or country (input) has  pass to the apex controller.
[ Eg:
1.country :USA State: NY---- input will be NY(State)
 2. country:Iceland  State : No States ,------ input will be  Iceland(Country) 
]
I dont know how to pass theat selected state picklist value to apex controller.

But i written some piece of codes.Please verify it and correct it. If anyone knows please tell me.

My Apex Code:

Public with sharing class SOSLController{
 Public List<loc__c> location {get;set;} // location
    public String imageURL{get;set;} // display a image
 Public String searchStr{get;set;} // find a string
 private ApexPages.StandardController stdController;
  /* display a image -method*/
 public  SOSLController(ApexPages.StandardController stdController)
  {
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where 
                                    Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
    /* find a string and  run the sosl query*/
  Public void soslDemo_method(){
   location = New List<loc__c>();
   if(searchStr.length() > 1){
   String searchStr1 = searchStr;
     //  System.debug('message');
       String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  loc__c(Comp__c, Type__c,Client__c, Competitor__c,Event_Name__c, evt_Des__c , Et_Addr__c, Dt_Ti__c, Ct_person__c,Ph_Num__c )';
   List<List <sObject>> searchList = search.query(searchQuery);
   location = ((List<loc__c>)searchList[0]);
       /* Message */
   if(location.size() == 0){
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Sorry, Type the location correctly or There is no details of the requested location found'));
       return;
   }}
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please enter the location..'));
   return;
   }}}

My VFP:

<apex:page standardController="Contact"  extensions="SOSLController"  sidebar="false" showHeader="false">
  <apex:form >
       <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Enter a location" id="acct1">
          <apex:outputLabel value="Country" />
          <apex:inputField value="{!contact.MailingCountryCode}" />
            <apex:outputLabel value="State" />
          <apex:inputField value="{!contact.MailingStateCode}" />
    <apex:commandButton value="Submit" action="{!soslDemo_method}"  reRender="acct,error,acct1" />
    <apex:outputPanel title="" id="error">
     <apex:pageMessages ></apex:pageMessages>
     </apex:outputPanel>
  </apex:pageBlock>
    <apex:pageBlock title="Details of technical events" id="acct">
    <apex:pageblockTable value="{!location }" var="acc">
           <apex:column value="{!acc.Comp__c}"/>
         <apex:column value="{!acc.Type__c}"/>
          <apex:column value="{!acc.Client__c}"/>
        <apex:column value="{!acc.Competitor__c}"/>
        <apex:column value="{!acc.Event_Name__c}"/>
          <apex:column value="{!acc.evt_Des__c}"/>
        <apex:column value="{!acc.Et_Addr__c}"/>
          <apex:column value="{!acc.Dt_Ti__c}"/>
        <apex:column value="{!acc.Ct_Person__c}"/>
          <apex:column value="{!acc.Ph_Num__c}"/>
       </apex:pageblockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>


Thanks and Regards,
Sivasankari.M
 
Hi All,
I created a custom object as accproducts__c,this object having one of the field is Product__c - it has the Product name from the Product standard object in sfdc. In table Product__c field holding Productid of  that Productname.
 Now, I create a one visualpage ,input of this page i want to give the picklist value of  Product__c(that input picklist field must be product name not a productid) .how to get it from controller. If anybody knows please tell me.


Thanks & Regard,
M. Sivasankari. .
hi,
Unable to connect salesforce outlook
User-added image
If any body knows pls tell me
Thanks & Regards,
M. Sivasankari
Hi,
<apex:pageBlockTable value="{!lstwrapper}" var="key" id="ptb">  
                     <apex:column HeaderValue="{!key.FF}" >
                     <apex:outputText value="{!key.data[key.FF]}" />
                     </apex:column>
 </apex:pageBlockTable>

HeaderValue are not display the table.Outputtext value not display in table format. full values are displayed in single column

Now I am getting the following result
User-added image
Thanks,
Hi All,

I have one custom ( vf page) button for generate quote in opportunity Detail Page. Click this button it generate a custom quote in pdf format.
 In my Scenario, I click that quote button I want to check whether the quote object “IsSyncing"  field is checked or not, If its not checked I want to display one alert for "sync Quote" I am using Professional Edition.
 
Hi All,
In my scenario,I have two objects Student_Academic and student_score,
Student_Academicobject contains :stuId,Name
User-added image
student_score Contains:stuId,Subject,Marks
User-added image
Page design is
User-added image
After click the save button the relevant marks and subject to that corresponding student store in student_score object

Thanks
Hi All,
In my scenario ,
Select page(input)-select industry and product
User-added image

Select page-click image
User-added image

Detail page- it shows relevant information about the image
User-added image

but in my case the detail page could not shows any informations.it couldn't receive any input from previous page(Select page).
My Code is:
Vfp-1(select page)
 
<apex:commandLink target="_blank" action="{!hello1}">
<apex:image value="{!account.photo__c}" height="150" width="200" id="test"   /> 
    
    </apex:commandLink>


My Controller page:
public PageReference  hello1(){
       PageReference pagr= new PageReference('/apex/custrefdetail');   
String searchStr1=ApexPages.currentPage().getParameters().get('searchStr'); //input - industry
     String productName1=ApexPages.currentPage().getParameters().get('productName');//input - product

accprd = [SELECT Detail__c,Product__c from  accproducts__c where Product__c =:productName1  and account__c in (select ID from Account where industry=:searchStr1)];
      System.debug(productName1);//product
      System.debug(searchStr1);//industry
              pagr.setRedirect(false); 
             return pagr;
	}
product and industry values shows as null. I dont know how to pass the detail value in visualforce page2.

if anybody knows please tell me.

Thanks,
M. Sivasankari.



 
Hi all,
I have two visualforce page and one controller in my scenario,
First page I give two input industry and product,its given the result certain group of company picture in href link.If I click one image it gives some relevent detail about the company its like  https://www.salesforce.com/customers/.


VFP-1
<apex:page sidebar="false" showheader="false" controller="sfdctest" tabStyle="account">
<apex:form >
<apex:pageMessages id="pId"/>
    <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Select a Industry & Product" >
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:selectList value="{!searchStr}" size="1"> 
                    <apex:selectOptions value="{!Industrynames}" />
          </apex:selectList>    
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <apex:selectList size="1" value="{!productName}">
            <apex:selectOptions value="{!items}"/>
    </apex:selectList> 
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <apex:outputPanel id="myRerender">

         <apex:commandButton value="Submit" action="{!soslDemo_method}"  ReRender="pgId,pId"  />
            </apex:outputPanel>

      </apex:pageBlock>
    
    <apex:pageBlock title="Customer details" id="pgId">
        
       <apex:repeat value="{!acc}" var="account">
     
             
<style>
    body {margin:50px;}
   
div.img {

    -webkit-align-items: baseline;
    align-items:baseline;
     margin: 10px;
    border: 1px solid #ccc;
    float: left;
    width: 220px;
   
    margin-bottom:25px;
    box:0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}    
  div.img:hover {
    
    border: 1px solid #777;
   
}

div.img img {
    max-width:100%;
    width: 100%;
    height: 150px;
    
}

    
div.desc {
    font-family:"arial";
    background-color : lightgrey;
    padding: 10px 20px;
   
    height: 50px;
    text-align: justify;
}   
 
    
   </style>      
 <body>
     

<div class="img" >

    <apex:outputLink target="_blank" value="{!$Page.custrefdetail}" id="tst" >   <!--   custrefdetail it is my second vfp -->
            <apex:image value="{!account.photo__c}" height="150" width="200"   /> 
        

            
     </apex:outputLink> 
    <div class="desc"><h1>
    
        {!account.Name}
        </h1>
        <p>
        {!account.Description}
        </p>
        </div>
   
</div>
    
     </body>
        </apex:repeat>
    </apex:pageBlock>
</apex:form>
</apex:page>
 
VFP: 2
<apex:page sidebar="false" showHeader="false" controller="sfdctest" action="{!hello1}" >
<apex:form >
  <apex:pageBlock >
    <apex:repeat value="{!accprd}" var="accs">
      <p>
     {!accs.Detail__c}
        </p>   

   </apex:repeat>  
        </apex:pageBlock>
     </apex:form>
  
</apex:page>

Controller

Public with sharing class sfdctest{
 Public List<Account> acc{get;set;} 
 Public List<accproducts__c> accprd{get;set;}
     public ApexPages.StandardSetController setController { get; set;}    
 public String imageURL{get;set;}
 Public String searchStr{get;set;} 
 public string productName{get;set;}

  public Void hello1(){
    accprd = New List<accproducts__c>(); 
     accprd = [SELECT Detail__c from  accproducts__c where Product__r.name =:productName  and account__c in (select ID from Account where industry=:searchStr)];
System.debug(productName);
   }

public List<selectoption> getIndustrynames()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
     options.add(new SelectOption('select','Select Industry'));     
    for (Schema.PicklistEntry a : values) 
    {                  
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options; 
}


public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('selectprd','Select Product')); 
    for(product2 c : [select ID, name  from product2  where ID IN( select Product__c from accproducts__c )]){
        options.add(new SelectOption(c.ID, c.name));
    }  
    return options;
}
    
 public  sfdctest()
  {
    acc = New List<Account>();
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
     
  Public void soslDemo_method(){
      System.debug(searchStr);
   if(searchStr.length() > 1 && searchStr != 'select'){
       acc = [SELECT Name,image__c,photo__c,Description,website from Account  where industry=:searchStr and Id in (select account__c from accproducts__c where Product__c = :productName )  ];
        System.debug('product');
       if(acc.size() == 0) {
           apexPages.addmessage(new apexpages.message(apexpages.severity.WARNING, 'Sorry, data not found'));
            return;
          }
       }

   else{
       acc = [SELECT Name,image__c,photo__c,Description,website from Account  where Id in (select account__c from accproducts__c )  ];
      
   }
  }
   }

 I try to display the hello1 method detail__c value  in my vfp2.


Thanks,
M. Sivasankari.
Hi Everyone,
 how to write a soql query 
we have two picklist. 
one is industry picklist-standard controller Account
another one is product(Product__c) picklist - custom object accproducts__c.
I want to pass these two picklist as a input to get a record 

I tried and doesn't work the query
select a.Name,a.ID,ap.Product__c from account a,accproducts__c ap where a.id=ap.account__c and ap.Product__r.name='GenWatt Propane 1500kW' and a.industry='banking'


error:Unknown error parsing query


Thanks,
​M. Sivasankari
 
Hi Everyone,
I have problem in soql query,
select a.Name,a.ID,ap.Product__c from account a,accproducts__c ap
where a.id=ap.account__c and ap.Product__r.name='GenWatt Propane 1500kW'  and a.industry='banking';
error:Unknown error parsing query

Standard object:Account
Custom Object :accproducts__c

if anybody knows the solution please tell me.

Thanks & Regard,
M. Sivasankari
Hi Everyone,

I want to get google map for current location viewing  & longitude and latitude without api key.

google javascript api v3  js file Link
https://maps.googleapis.com/maps/api/js

Codes:

1.VF Code:
<apex:page sidebar="false" showheader="false" standardController="Account"  extensions="FindNearby">
    
    <!-- Include in Google's Maps API via JavaScript static resource -->
    <apex:includeScript value="{!$Resource.googleMapsAPI}" /> 
    
    <!-- Set this API key to fix JavaScript errors in production -->
    <!--http://salesforcesolutions.blogspot.com/2013/01/integration-of-salesforcecom-and-google.html-->
    <script type="text/javascript" 
       src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> <!-- We try to get google mapy without API Key (Javascript V3) but i did not show the current location as well as longitude and latitude -->
<!-- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAowmYdY3dZwoe4qI1I_X8Ry-UPepb5dpA&sensor=false">   previously we used API key to generate Google Map but  the usage of API key is very limited(Only 4 times)  -->

        </script>
        
    <!-- Setup the map to take up the whole window --> 
    <style>
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
    </style>
    
    <script>
        function initialize() {
            var lat, lon;
              
             // If we can, get the position of the user via device geolocation
             if (navigator.geolocation) {
                 navigator.geolocation.getCurrentPosition(function(position){
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     
                     // Use Visualforce JavaScript Remoting to query for nearby accts      
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.FindNearby.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 console.log(result);
                                 createMap(lat, lon, result);           
                             } else if (event.type === 'exception') {
                                 //exception case code          
                             } else {
                                            
                             }
                          }, 
                          {escape: true}
                      );
                  });
              } else {
                  // Set default values for map if the device doesn't have geolocation capabilities
                    /** Eindhoven **/
                    lat = 12.9172;
                    lon = 80.1929;
                    
                    var result = [];
                    createMap(lat, lon, result);
              }
          
         }
    
         function createMap(lat, lon, accts)
    {
            // Get the map div, and center the map at the proper geolocation
            var currentPosition = new google.maps.LatLng(lat,lon);
            var mapDiv = document.getElementById('map-canvas');
            var map = new google.maps.Map(mapDiv, {
                center: currentPosition, 
                zoom: 13,
                mapTypeId: google.maps.MapTypeId.ROADTYPE
            });
           
            // Set a marker for the current location
            var positionMarker = new google.maps.Marker({
                map: map,
                position: currentPosition,
                icon: 'http://maps.google.com/mapfiles/ms/micons/pink.png'
            });
            
                        
            // Keep track of the map boundary that holds all markers
            var mapBoundary = new google.maps.LatLngBounds();
            mapBoundary.extend(currentPosition);
            
            // Set markers on the map from the @RemoteAction results
            var acct;
            for(var i=0; i<accts.length;i++){
                acct = accts[i];
                console.log(accts[i]);
                setupMarker();
            }
            
            // Resize map to neatly fit all of the markers
            map.fitBounds(mapBoundary);

           function setupMarker(){ 
                var acctNavUrl;
                
                // Determine if we are in Salesforce1 and set navigation link appropriately
                try{
                    if(sforce.one){
                        acctNavUrl = 
                            'javascript:sforce.one.navigateToSObject(\'' + acct.Id + '\')';
                    }
                } catch(err) {
                    console.log(err);
                    acctNavUrl = '\\' + acct.Id;
                }
                
                var acctDetails = 
                    '<a href="' + acctNavUrl + '">' + 
                    acct.Name + '</a><br/>' + 
                    acct.BillingStreet + '<br/>' + 
                    acct.BillingCity + '<br/>' + 
                    acct.Phone;
               
               // Create the callout that will pop up on the marker     
               var infowindow = new google.maps.InfoWindow({ 
                   content: acctDetails
               });
               
               // Place the marker on the map   
               var marker = new google.maps.Marker({
                   map: map,
                   position: new google.maps.LatLng( 
                                   acct.Location__Latitude__s, 
                                   acct.Location__Longitude__s)
               });
               mapBoundary.extend(marker.getPosition());
               
               // Add the action to open up the panel when it's marker is clicked      
               google.maps.event.addListener(marker, 'click', function(){
                   infowindow.open(map, marker);
               });
           }
        }
        
        // Fire the initialize function when the window loads
        google.maps.event.addDomListener(window, 'load', initialize);
        
    </script>
    
    
    <body style="font-family: Arial; border: 0 none;">
       
   <!--  All content is rendered by the Google Maps code -->
    <!--  This minimal HTML justs provide a target for GMaps to write to -->
        <div id="map-canvas"></div>
    </body>
</apex:page>

2.Apex Class --- FindNearby
global with sharing class FindNearby {

   public FindNearby(ApexPages.StandardController sc){} 
    
    @RemoteAction
    // Find Accounts nearest a geolocation
    global static List<Account> getNearby(String lat, String lon) {

        // If geolocation isn't set, use Eindhoven (or any other city)
        // Put a default location latitue and longitude here, this could be where you are located the most
        // and will only be used as a backup if the browser can not get your location details
        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '51.096214';
            lon = '3.683153';
        }

        // SOQL query to get the nearest accounts
        //you can change km (kilometers) into mi (miles)
        // < 20 means within a radius of 20 km or mi (you can change that)
        //limit 25 shows 25 records (you can adapt that too if you want)
        String queryString =
            'SELECT Id, Name, Location__Longitude__s, Location__Latitude__s, ' +
                'BillingStreet, Phone, BillingCity ' +
            'FROM Account ' +
            'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 20 ' +
            'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') ' +
            'LIMIT 25';

        // Run and return the query results
        return(database.Query(queryString));
    }
}

3.Apex Trigger
// Trigger runs getLocation() on Accounts with no Geolocation
trigger SetGeolocation on Account (after insert, after update) {
    for (Account a : trigger.new){
        if(Trigger.isUpdate){
            if(a.BillingStreet != Trigger.oldMap.get(a.id).BillingStreet || a.BillingCity != Trigger.oldMap.get(a.id).BillingCity || a.BillingPostalCode != Trigger.oldMap.get(a.id).BillingPostalCode){
                LocationCallouts.getLocation(a.id);
            }
        }
        if (a.Location__Latitude__s == null)
            LocationCallouts.getLocation(a.id);
}
}

4.Apex Class

public class LocationCallouts {
 
     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setMethod('GET');
        req.setTimeout(6000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug(res.getBody());
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.Location__Latitude__s = lat;
                a.Location__Longitude__s = lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}

Thanks in advance,
If anybody know please tell me.

Thanks and Regards,
Sivasankari.M
Hi All,
I created a custom object as accproducts__c,this object having one of the field is Product__c - it has the Product name from the Product standard object in sfdc. In table Product__c field holding Productid of  that Productname.
 Now, I create a one visualpage ,input of this page i want to give the picklist value of  Product__c(that input picklist field must be product name not a productid) .how to get it from controller. If anybody knows please tell me.


Thanks & Regard,
M. Sivasankari. .
Hi, 
how to create email template for lead fields 
I tried ,
Step 1:
User-added image
Step 2:
User-added image

Please tell me ,If anybody Know
Hi everyone,
    I am getting error  " Unknown property 'customref.Account' " in  VisualForce Page. Please review the code.
Let me know where i did mistake.

Thanks in Advance,
SivaSankari

Apex Code:
Public with sharing class customref{
 Public List<Account> acc{get;set;} 
    public String imageURL{get;set;}
 Public String searchStr{get;set;} // find a string

    /* display a image -method*/
 public  customref()
  {
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where 
                                    Name='logo'];
   
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
    
    /* find a string and  run the sosl query*/
  Public void soslDemo_method(){
   acc = New List<Account>();
 
   if(searchStr.length() > 1){
   String searchStr1 = searchStr;
       String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  Account( Firstname,lastname )';
   List<List <sObject>> searchList = search.query(searchQuery);
   acc= ((List<Account>)searchList[0]);
       /* Message */
   if(acc.size() == 0){
       apexPages.addmessage(new apexpages.message(apexpages.severity.WARNING, 'Sorry, data not found'));
       return;
   }
   }
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please select the industry..'));
   return;
   }
  }
}

VF Code ;
<apex:page  controller="customref" tabstyle="Account" >
  <apex:form >
       <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Select a Industry" >
                 <apex:outputLabel value="Inustry:"/>
                 <apex:inputfield  value="{! Account.Industry}"/>   
    <apex:commandButton value="Submit" action="{!customref}"  />
   </apex:pageBlock>
    <apex:pageBlock title="Customer details">
    <apex:pageblockTable value="{!Account }" var="acc">
      
          <apex:column value="{!acc.Firstname}"/>
         <apex:column value="{!acc.lastname}"/>
          
       </apex:pageblockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

Nomal behaviour in vf tables is to display one object per row of a table, with your desired fields as columns.

I'm trying to create a page where only one field per object is shown but they are displayed horizontally.

 

<apex:dataTable id="teamtable" value="{!MyTeam}" var="person">
  <apex:column > <apex:image url="{!person.Photo_URL__c}" height="150" width="200" /> </apex:column>
  <apex:column > <apex:outputText value="{!person.Name__c}" /> </apex:column>
</apex:dataTable>

 

So this is displaying all the team members vertically with a lot of white space on the right. Ideally I'd like to have 4 or 5 team members photos on a line each with their name underneath. Is this possible in VF ?