• nicloz
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 14
    Replies

Dears

 

May anybody helpe with this issue? I cannot make a callout from my trigger, please to see the call please follow the link (link of this community) to another case that ass the complete trigger and class.

 

Link to track and see the complete code: http://boards.developerforce.com/t5/Apex-Code-Development/ApexCode-bug/m-p/210323#M37315

 

Important to mention that I am using   @future (callout=true).

 

I hope someone can help me.

 

Thanks in advance.

  • October 22, 2010
  • Like
  • 0

Dears

 

I installed salesforce for twitter in app exchange web page, I read this manual http://www.scribd.com/doc/24039811/Salesforce-for-Twitter-Setup-Guide but I cannot find the button to grant access to connect with twitter (New OAuth), I already write the user in the password field I wrote the pass but I got a message thar explain that I need to grand access first, right now I cannot send any message to my twitter account.

 

Best Regards

  • October 21, 2010
  • Like
  • 0

Dears

 

After read and change my class acording to this manual http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods I got 74% of coverage of my code, second issue after change my class with these three method I cannot complete the request, I got this error "Callout from triggers are currently not supported.: Class.APICallV2.invokeWebService: line 44, column 28" my  class has  @future (callout=true), is important to note that the last class (http://boards.developerforce.com/t5/Apex-Code-Development/Test-API-Call-Future-callout-true/td-p/207766) work perfect in sandbox but is not posible to test and migrate to production (link with the class and advise http://boards.developerforce.com/t5/Apex-Code-Development/Test-API-Call-Future-callout-true/td-p/207766) below the code for your advise:

 

 

 

trigger Event_Trigger on Event( after insert, before update) {//verificar funcionamiento de future call con update before
/*
si cambia a.RecordTypeId el nombre o el ID del campo de debe cambiar en cada if el codigo anterior (012A0000000Bg6CIAS)
*/
   System.debug('Making future call');
    
    for (Event a : Trigger.new) {
        if (Trigger.isInsert) {
            
            if(a.RecordTypeId != '012A0000000Bg6CIAS'){//only for recordtype Masivo, this value (012A0000000Bg6CIAS) can not change
            

/*******getting info for below procedures***************/
            List<Account> l = [Select Account.latitud__c, Account.Categoria__c From Account Where Id=:a.WhatId];
            string latitud = l[0].latitud__c ;
            string tipo_cliente = l[0].Categoria__c ;
             string Categoria = l[0].Categoria__c ;
   
 
           if(latitud == null){// if latitude is not completed the user need to go to account and set the latitude and longitude values
                a.addError(' No es posible crear la visita, por favor dirigase al módulo de Cliente y agrega las latitud y longitud de la dirección utilizando el mapa. ');
           }
       
            string contact_preson =     a.WhatId;//contact ID for Rest API
            string Id_event =     a.Id; //ID of event for REST API
     
    
          Datetime inicio = a.StartDateTime; //Date of start meeting
          Datetime fin    = a.EndDateTime;  //Date of end meeting
       
/*****Section to check is the meeting is point for the same month.****/
       date startDate =  date.today();
       date dueDate = date.newInstance(inicio.year(),inicio.month(),inicio.day());
       integer numberMonthsDue = startDate.monthsBetween(dueDate);

        integer tot;
           if(numberMonthsDue == 0 ){
                integer c = [SELECT count() FROM Event where OwnerId=:a.OwnerId  and  WhatId=:a.WhatId and  StartDateTime = THIS_MONTH];
                tot = c;
            }
            if(numberMonthsDue > 0 ){
                integer c = [SELECT count() FROM Event where OwnerId=:a.OwnerId  and  WhatId=:a.WhatId and  StartDateTime = NEXT_MONTH];
                tot = c;
            }
            
               //section visit per type of client


              if(tipo_cliente == 'Uno (1)'){//cada 15 dias
                 if(tot > 2){//menor a dos visitas mensiales
                       a.addError(' No es posible crear mas de 2 visitas por mes para este cliente, en caso de no poder asistir a visitas previamente programadas para este mes, por favor ingrese nuevamente a esa visita y reprograme. ' );
                       //+tot+' '+Categoria+' lat '+latitud+' what id '+a.WhatId+' whot id '+a.WhoId
                 }
              }
             if(tipo_cliente == 'Dos (2)'){//cada 30 dias
                if(tot > 4){//menor a tres visitas mensiales
                       a.addError(' No es posible crear mas de 4 visitas por mes para este cliente, en caso de no poder asistir a visitas previamente programadas para este mes, por favor ingrese nuevamente a esa visita y reprograme. '+tot);
                 }
              }
            if(tipo_cliente == 'Cuatro (4)'){//cada semana
                if(tot > 8){//menor a cinco visitas mensuales
                       a.addError(' No es posible crear mas de 8 visitas por mes para este cliente, en caso de no poder asistir a visitas previamente programadas para este mes, por favor ingrese nuevamente a esa visita y reprograme. '+tot);
                 }
            }


               //END section visit per type of client           

//send te data future method
              Http h = new Http();
            APICallV2 v = new APICallV2();
           HttpRequest req =  v.buildWebServiceRequest();
            v.invokeWebService(h, req,inicio,fin,Id_event,contact_preson );
           

           }//si no es negocio (recordtype)
        }//isinsert
    }//trigger new
    
    
    for (Event a : Trigger.new) {
        if (Trigger.isUpdate) {//para update
        
         if(a.RecordTypeId != '012A0000000Bg6CIAS'){//only for recordtype Masivo, this value (012A0000000Bg6CIAS) can not change
         if(a.Fecha_inicio_real__c == null && a.Fecha_Hora_fin_real__c ==null && !a.Efectividad_de_la_visita__c){
         
         /*******getting info for below procedures***************/
         List<event> e = [Select Event.StartDateTime From Event Where Id=:a.Id];

   //     Datetime Date_Start_old = datetime.now() ;
     //    Datetime Date_Start_new = datetime.now();
        Datetime Date_Start_old = e[0].StartDateTime ;
        Datetime Date_Start_new = a.StartDateTime;
        
        
        string contact_preson =     a.WhatId;//contact ID for Rest API
        string Id_event =     a.Id; //ID of event for REST API
        Datetime inicio = a.StartDateTime; //Date of start meeting
        Datetime fin    = a.EndDateTime;  //Date of end meeting
        
        
        /*****Section to reschedule forthe same month.****/
        Date Date_Start_new_date  = date.newInstance(Date_Start_new.year(), Date_Start_new.month(), Date_Start_new.day());//se pasa a formato date
        Date Date_Start_old_date  = date.newInstance(Date_Start_old.year(), Date_Start_old.month(), Date_Start_old.day());//se pasa a formato date
        integer numberDaysDue =Date_Start_old_date.daysBetween(Date_Start_new_date);
        
        integer numberMonthsDue =Date_Start_old_date.monthsBetween(Date_Start_new_date);
               if( numberMonthsDue > 0){//msj de error
                    a.addError(' Usted dede reprogramar su la visita en el mes en curso.');
                }// > 10
 
             
             
                  Http h = new Http();
            APICallV2 v = new APICallV2();
           HttpRequest req =  v.buildWebServiceRequest();
            v.invokeWebService(h, req,inicio,fin,Id_event,contact_preson );
           }
         }//si no es negocio recordtype.
        
        }//isbefore

}//trigger old
}//principal

 

 

 

Continue below........


Could you please clarify if this error represent a bug in salesforce?

  • October 07, 2010
  • Like
  • 0

Dears

 

I create visual force page that connect to google map and display it in account module, the map works perfect in firefox, but when I run it in Internet Explores i got a message inform that "This page ha content that won´t be sent using a secure HTTPS" (message summary) and I have two options "Yes" or "No" when I click in Yes the map is not displayed, when I click "No" the map is displayed but in a wrong latitude, longitude address, how may I solve this issue with internet exploere? Below the code:

 

 

<apex:page standardController="Account" extensions="lat_lon_GoogleMap"    >
 

 <html>
  <head>
    <script type="text/javascript"
            src="http://www.google.com/jsapi?key=ABQIAAAAe2NFOp1WA-r3hEnPeArUrBST0mNpJvtWvmgvEdrgGXs5szHHahQf0jJpikHErriZM-CeKx3OJZgXvQ"></script>
    <script type="text/javascript">
       
    var geocoder;
    var address;
    //standardController="Account" extensions="lat_lon_GoogleMap"
      google.load("maps", "2");
      google.load("search", "1");

      // Call this function when the page has been loaded
      function initialize() {

 

/****display map in div*****/

        var map = new google.maps.Map2(document.getElementById("map"));
/**** in my opinion only display the map until this section*******/    

 

 

/**** Thsi section is not displayed, the address*******/

             map.setCenter(new google.maps.LatLng(10.4974997, -66.8445959), 15);
              map.openInfoWindow(map.getCenter(),
                       document.createTextNode("Please complete info"));//msj

        
        map.setMapType(G_HYBRID_MAP);//G_HYBRID_MAP, G_SATELLITE_MAP
        map.setUIToDefault();
        GEvent.addListener(map, "click", getAddress);
      geocoder = new GClientGeocoder();

      }
        function getAddress(overlay, latlng) {

      if (latlng != null) {
        address = latlng;
        geocoder.getLocations(latlng, showAddress);
      }
    }
    
     function showAddress(response) {
                
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                             place.Point.coordinates[0]);
         
              
 

      if (!response || response.Status.code != 200) {

        alert("Por favor contacte al administrador, no se guardaron las Coordenadas, Status Code:" + response.Status.code);
      } else {
        
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
 
 


        }
    }
    
 
   
      
      google.setOnLoadCallback(initialize);
      }//si no tiene lat
      
  
    </script>

  </head>
 
  <body>
 <apex:form id="form1">

 <apex:pageMessages id="error"/>

    <!--   Display info-->


 </apex:form>
<!--   Display map-->
 <div id="map"  style="width: 950px; height: 700px">    </div>
 
 
  </body>

</html>


   </apex:page>

 

 

 

 

 

 

Thanks in advances

  • October 01, 2010
  • Like
  • 0

Dears

 

I am self learning and apex code manual reader, my company has an important project with one of the most important Telecomunication company in Venezuela , I am trying to save two file obtained from javascript code into account object, I created a controller class that received the three values from javascript, but I cannot take the ID of the current account that I am working, this VS page display a map when you want to update or modify the account info that show me latitude and longitude of the selected point of the map (javascript values), is important to note that I already try setting ID that exist in the account object but it does not work, below the resume code:

 

//controller, it is the name of the class

<apex:page controller="lat_lon_GoogleMap"  >

 

//Javascript values

place.Point.coordinates[0];
place.Point.coordinates[1];

 

//method name of the class with the parameters.

save_lat_lon (place.Point.coordinates[1], place.Point.coordinates[0],Account.Id); //Account.Id setting this value to existing ID does not work.

 

//How to get the ID of the account, before user the controles controller="lat_lon_GoogleMap", I could get the ID through Account.ID but using standarcontrolles="Account", how can I get this ID using controler "lat_lon_GoogleMap". I cannot use both, I got an error from salesforce that I cannot user two controlers.

 

  </apex:page>

 

 

 

/*********************************************** the class (controller)*************************************************/

 

/****clase para almacenar datos del mapa****/
public with sharing class lat_lon_GoogleMap{


    /****metodo que se llama en la pagina para almacenar datos del mapa****/
    public static void save_lat_lon (string lat, string lon, string Account_Id) {//method called in VF page.



//remember that Account_Id value is empty because I cannot get this ID in the VF page.

 

      Account acc = new Account(Id=Account_Id);
        acc.Latitud__c = lat;
        acc.Longitud__c = lon;
        update acc;
 
    }

 

}//class

 

 

 

I hope this explanation is clear for you.

 

Best Regards

  • September 06, 2010
  • Like
  • 0

Dears

 

Please could you help me with this issue?  I integrate a google map that display the latitude and longitude after the user click over the map, I can see the javascript alert witht the lat and long but I don't know how to display this value in a custom field e.g name fiel "latitud_prueba__c" , and I have a issue with "addOverlay", If I can display only the value in that field is ok, is the most important to me.

 

Let me explain the procedure:

1) I create a Visual Force page in Development section

2) Then in Customize and add to the Contact layout the page created before in a ne section with all the standar field of this module (Contact) and personalized fields for example latitud_prueba__c.

3) Then I go to module Contact, select a contact and I can see the map, when I made click I can see the javascrpt aler message with the Latitude and Longitude of the map, but how to display e.g latitude in the dield latitud_prueba__c created and displayed in the contact layout.

 

Below the code

 

 

<apex:page standardController="contact">

 <html>
  <head>
    <script type="text/javascript"
            src="http://www.google.com/jsapi?key=ABQIAAAAe2NFOp1WA-r3hEnPeArUrBST0mNpJvtWvmgvEdrgGXs5szHHahQf0jJpikHErriZM-CeKx3OJZgXvQ"></script>
    <script type="text/javascript">
    
    var geocoder;
    var address;
    
      google.load("maps", "2");
      google.load("search", "1");

      // Call this function when the page has been loaded
      function initialize() {
        var map = new google.maps.Map2(document.getElementById("map"));
        map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);
        
        map.setUIToDefault();
        GEvent.addListener(map, "click", getAddress);
      geocoder = new GClientGeocoder();

      }
        function getAddress(overlay, latlng) {

      if (latlng != null) {
        address = latlng;
        geocoder.getLocations(latlng, showAddress);
      }
    }
    
     function showAddress(response) {
                
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                             place.Point.coordinates[0]);
         
              
    //  alert(point);   // I can see lat y long

      if (!response || response.Status.code != 200) {

        alert("Status Code:" + response.Status.code);
      } else {
        
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
           
        marker = new GMarker(point);
        map.addOverlay(marker); // in this section a have an error, the code just stop and do not continue.
 
      // alert(place.Point.coordinates[1]+' resp 5 '+response.Status.code);   // display the lat y long, If I didn't comment with "//" the last line of code (map.addOverlay(marker)) I wont see this alert.
        marker.openInfoWindowHtml(
        '<b>orig latlng:</b>' + response.name + '<br/>' +
        '<b>latlng:</b>' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' +
        '<b>Status Code:</b>' + response.Status.code + '<br>' +
        '<b>Status Request:</b>' + response.Status.request + '<br>' +
        '<b>Address:</b>' + place.address + '<br>' +
        '<b>Accuracy:</b>' + place.AddressDetails.Accuracy + '<br>' +
        '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
      }
    }
    
 
   
      
      google.setOnLoadCallback(initialize);
    </script>

  </head>
 
  <body>
    <div id="map" style="width: 600px; height: 300px"></div>
    <div id="searchcontrol"></div>
  </body>

</html>

</apex:page>

 

 

Best Regards

Dears

 

I would like to know how to display a value in any field of my form Contact. I get the value from a JavaScript function after that I need to send the value and  dislay in the field Phone Number (example) module Contact.

 

Below  the code

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>

   <script type="text/javascript">

 


function test(){

var  abc;

                  //this part of the code work but is not what I want.

               document.getElementById("lat").value=  abc   --> "Value get form another Javascript function";

 

// I want to display the value of "var  abc"  in the field phone numbe rof module contact

 

}

 

</script>      
  </head>
  <body  style="font-family: Arial;border: 0 none;">

    <div id="map_canvas" style="width: 700px; height: 400px">

<input name="lat" id="lat" type="text" readOnly="true" />

 

<!--  Display info  -->

</div>
  </body>
</html>

Dears

 

Please could you help me to parse a XML code that contain the latitude and longitude of address? Below the XML code I try with the manual but I has for soap and the another example is too simple to parse this complicated XML of google.

 

I want to take the value of latitude and longitude.

 

Thanks in advances

 

<GeocodeResponse> 
 
<status>OK</status>
 
<result>
 
<type>street_address</type>
 
<formatted_address>1600 Amphi Pkwy, Mountain, CA 94043, USA</formatted_address>
 
<address_component>
   
<long_name>1600</long_name>
   
<short_name>1600</short_name>
   
<type>street_number</type>
 
</address_component>
 
<address_component>
   
<long_name>Amphitheatre Pkwy</long_name>
   
<short_name>Amphitheatre Pkwy</short_name>
   
<type>route</type>
 
</address_component>
 
<address_component>
   
<long_name>Mountain View</long_name>
   
<short_name>Mountain View</short_name>
   
<type>locality</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>San Jose</long_name>
   
<short_name>San Jose</short_name>
   
<type>administrative_area_level_3</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>Santa Clara</long_name>
   
<short_name>Santa Clara</short_name>
   
<type>administrative_area_level_2</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>California</long_name>
   
<short_name>CA</short_name>
   
<type>administrative_area_level_1</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>United States</long_name>
   
<short_name>US</short_name>
   
<type>country</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>94043</long_name>
   
<short_name>94043</short_name>
   
<type>postal_code</type>
 
</address_component>
 
<geometry>
   
<location>
   
<lat>37.4217550</lat>
   
<lng>-122.0846330</lng>
   
</location>
   
<location_type>ROOFTOP</location_type>
   
<viewport>
   
<southwest>
     
<lat>37.4188514</lat>
     
<lng>-122.0874526</lng>
   
</southwest>
   
<northeast>
     
<lat>37.4251466</lat>
     
<lng>-122.0811574</lng>
   
</northeast>
   
</viewport>
 
</geometry>
 
</result>
</GeocodeResponse>
  • April 27, 2010
  • Like
  • 0

Dears

 

I need to add a page in contact module that show a static google map, this map will be created after send via URL some data needed by google to create the map.

 

Below the link:

 

http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap
&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318
&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false

 

This is a test link I will pass the address of contac for each user.

 

Best Regards

  • April 22, 2010
  • Like
  • 0

Dears

 

Please could help me the way to add one hour and get one hour less in another datetime field? I need to do that because the process need to track the time one hour less in the case of start time and one more in the end time.

 

 

Format: 2010-04-22T12:12:00.000

Type: Datetime

 

Best Regards

  • April 22, 2010
  • Like
  • 0

Dears

 

Please could you help me to get the correct code to the below  issue? I need to take the value of the field name or address and save into a string value, after that these strings I will send via XML to external server.

 

Account a = [SELECT Name FROM Account WHERE Name = 'Foo' LIMIT 1];
String s = a.Name;// I can save it, but when I run the application I get another error.
String c = Account.Name;//second option I get the error "Illegal assignment from Schema.SObjectField to String".
  • April 21, 2010
  • Like
  • 0

Hi, Please could you help me take one value from a field of object contact? This is my code, it is not working properly(the result is null), the ID 0033000000bOWgWAAW exist and the name of the field is correct, I want to take a value of field address and send it via url to external web service.

 

    contact cont = new contact(Id = '0033000000bOWgWAAW');
    string name2 = cont.FirstName; /// the result is null

 

All this code is inside a class or inside a trigger.

 

I thing this is a simple thing but I am stuck. (I check the book "apex code developer's guide Version 18").

 

Thanks in advance

  • April 13, 2010
  • Like
  • 0

Dears

 

I installed salesforce for twitter in app exchange web page, I read this manual http://www.scribd.com/doc/24039811/Salesforce-for-Twitter-Setup-Guide but I cannot find the button to grant access to connect with twitter (New OAuth), I already write the user in the password field I wrote the pass but I got a message thar explain that I need to grand access first, right now I cannot send any message to my twitter account.

 

Best Regards

  • October 21, 2010
  • Like
  • 0

Dears

 

After read and change my class acording to this manual http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods I got 74% of coverage of my code, second issue after change my class with these three method I cannot complete the request, I got this error "Callout from triggers are currently not supported.: Class.APICallV2.invokeWebService: line 44, column 28" my  class has  @future (callout=true), is important to note that the last class (http://boards.developerforce.com/t5/Apex-Code-Development/Test-API-Call-Future-callout-true/td-p/207766) work perfect in sandbox but is not posible to test and migrate to production (link with the class and advise http://boards.developerforce.com/t5/Apex-Code-Development/Test-API-Call-Future-callout-true/td-p/207766) below the code for your advise:

 

 

 

trigger Event_Trigger on Event( after insert, before update) {//verificar funcionamiento de future call con update before
/*
si cambia a.RecordTypeId el nombre o el ID del campo de debe cambiar en cada if el codigo anterior (012A0000000Bg6CIAS)
*/
   System.debug('Making future call');
    
    for (Event a : Trigger.new) {
        if (Trigger.isInsert) {
            
            if(a.RecordTypeId != '012A0000000Bg6CIAS'){//only for recordtype Masivo, this value (012A0000000Bg6CIAS) can not change
            

/*******getting info for below procedures***************/
            List<Account> l = [Select Account.latitud__c, Account.Categoria__c From Account Where Id=:a.WhatId];
            string latitud = l[0].latitud__c ;
            string tipo_cliente = l[0].Categoria__c ;
             string Categoria = l[0].Categoria__c ;
   
 
           if(latitud == null){// if latitude is not completed the user need to go to account and set the latitude and longitude values
                a.addError(' No es posible crear la visita, por favor dirigase al módulo de Cliente y agrega las latitud y longitud de la dirección utilizando el mapa. ');
           }
       
            string contact_preson =     a.WhatId;//contact ID for Rest API
            string Id_event =     a.Id; //ID of event for REST API
     
    
          Datetime inicio = a.StartDateTime; //Date of start meeting
          Datetime fin    = a.EndDateTime;  //Date of end meeting
       
/*****Section to check is the meeting is point for the same month.****/
       date startDate =  date.today();
       date dueDate = date.newInstance(inicio.year(),inicio.month(),inicio.day());
       integer numberMonthsDue = startDate.monthsBetween(dueDate);

        integer tot;
           if(numberMonthsDue == 0 ){
                integer c = [SELECT count() FROM Event where OwnerId=:a.OwnerId  and  WhatId=:a.WhatId and  StartDateTime = THIS_MONTH];
                tot = c;
            }
            if(numberMonthsDue > 0 ){
                integer c = [SELECT count() FROM Event where OwnerId=:a.OwnerId  and  WhatId=:a.WhatId and  StartDateTime = NEXT_MONTH];
                tot = c;
            }
            
               //section visit per type of client


              if(tipo_cliente == 'Uno (1)'){//cada 15 dias
                 if(tot > 2){//menor a dos visitas mensiales
                       a.addError(' No es posible crear mas de 2 visitas por mes para este cliente, en caso de no poder asistir a visitas previamente programadas para este mes, por favor ingrese nuevamente a esa visita y reprograme. ' );
                       //+tot+' '+Categoria+' lat '+latitud+' what id '+a.WhatId+' whot id '+a.WhoId
                 }
              }
             if(tipo_cliente == 'Dos (2)'){//cada 30 dias
                if(tot > 4){//menor a tres visitas mensiales
                       a.addError(' No es posible crear mas de 4 visitas por mes para este cliente, en caso de no poder asistir a visitas previamente programadas para este mes, por favor ingrese nuevamente a esa visita y reprograme. '+tot);
                 }
              }
            if(tipo_cliente == 'Cuatro (4)'){//cada semana
                if(tot > 8){//menor a cinco visitas mensuales
                       a.addError(' No es posible crear mas de 8 visitas por mes para este cliente, en caso de no poder asistir a visitas previamente programadas para este mes, por favor ingrese nuevamente a esa visita y reprograme. '+tot);
                 }
            }


               //END section visit per type of client           

//send te data future method
              Http h = new Http();
            APICallV2 v = new APICallV2();
           HttpRequest req =  v.buildWebServiceRequest();
            v.invokeWebService(h, req,inicio,fin,Id_event,contact_preson );
           

           }//si no es negocio (recordtype)
        }//isinsert
    }//trigger new
    
    
    for (Event a : Trigger.new) {
        if (Trigger.isUpdate) {//para update
        
         if(a.RecordTypeId != '012A0000000Bg6CIAS'){//only for recordtype Masivo, this value (012A0000000Bg6CIAS) can not change
         if(a.Fecha_inicio_real__c == null && a.Fecha_Hora_fin_real__c ==null && !a.Efectividad_de_la_visita__c){
         
         /*******getting info for below procedures***************/
         List<event> e = [Select Event.StartDateTime From Event Where Id=:a.Id];

   //     Datetime Date_Start_old = datetime.now() ;
     //    Datetime Date_Start_new = datetime.now();
        Datetime Date_Start_old = e[0].StartDateTime ;
        Datetime Date_Start_new = a.StartDateTime;
        
        
        string contact_preson =     a.WhatId;//contact ID for Rest API
        string Id_event =     a.Id; //ID of event for REST API
        Datetime inicio = a.StartDateTime; //Date of start meeting
        Datetime fin    = a.EndDateTime;  //Date of end meeting
        
        
        /*****Section to reschedule forthe same month.****/
        Date Date_Start_new_date  = date.newInstance(Date_Start_new.year(), Date_Start_new.month(), Date_Start_new.day());//se pasa a formato date
        Date Date_Start_old_date  = date.newInstance(Date_Start_old.year(), Date_Start_old.month(), Date_Start_old.day());//se pasa a formato date
        integer numberDaysDue =Date_Start_old_date.daysBetween(Date_Start_new_date);
        
        integer numberMonthsDue =Date_Start_old_date.monthsBetween(Date_Start_new_date);
               if( numberMonthsDue > 0){//msj de error
                    a.addError(' Usted dede reprogramar su la visita en el mes en curso.');
                }// > 10
 
             
             
                  Http h = new Http();
            APICallV2 v = new APICallV2();
           HttpRequest req =  v.buildWebServiceRequest();
            v.invokeWebService(h, req,inicio,fin,Id_event,contact_preson );
           }
         }//si no es negocio recordtype.
        
        }//isbefore

}//trigger old
}//principal

 

 

 

Continue below........


Could you please clarify if this error represent a bug in salesforce?

  • October 07, 2010
  • Like
  • 0

Dears

 

I need to release this api call for our client, the coverage of my test is 67%, like you know I need at least 75% how I can get the 75%? Below the code.

 

public class APICall {

 
  //Future annotation to mark the method as async.
  @Future(callout=true)


//  String id, String name
public static void APICall_Request (Datetime fecha_inicio, Datetime fecha_fin, string Event_Id, string account_Id) {

        HttpRequest req = new HttpRequest();
 
        req.setEndpoint('https://apisphere.locationsmart.com/restapi/v_1_1/sphere');
        req.setMethod('POST');
        

/****getting info from table Account***/

      List<account> b = [Select latitud__c, Longitud__c From Account Where Id=:account_Id];
 

    string latitud = b[0].latitud__c; //info for the XML
    string Longitud = b[0].Longitud__c; //info for the XML
      
    /****converting the datetimne*******/
    Datetime fecha_fin_def   = fecha_fin.AddHours(1);//time dif our time -4:30 GMT (time difference with your servers and salesforce)
    Datetime fecha_inic_def  = fecha_inicio.AddHours(-1);//time dif -4:30 GMT (time difference with your servers and salesforce)
    
/******** XML*******/
      req.setBody( '<request>    <authentication>        <username>65460806</username>        <password>hello</password>    </authentication>    <sphere>        <name>'+Event_Id+'</name>  <campaign>DEMO</campaign>      <onEnter>           <processId>6540088</processId>          <processPayload>&lt;payload&gt;&lt;value&gt;'+Event_Id+'&lt;/value&gt;&lt;/payload&gt;</processPayload>        </onEnter>        <onExit>            <processId>6540088</processId>           <processPayload>&lt;payload&gt;&lt;value&gt;'+Event_Id+'&lt;/value&gt;&lt;/payload&gt;</processPayload>      </onExit>        <device>65460806</device>                <zone>            <address>'+Longitud+' '+latitud+'</address>            <radius>90</radius>            <unitType>mtrs</unitType>        </zone>        <startDate>'+fecha_inic_def+' +0000</startDate>        <endDate>'+fecha_fin_def+' -0000</endDate>    </sphere></request>');

        // Create a new http object to send the request object
        // A response object is generated as a result of the request
        Http http = new Http();
        HTTPResponse res = http.send(req);
        req.setMethod('POST');

 

/********************** the result is ok sucessful this function and the connection is working fine *************************/

 

     //check the response
    if (res.getStatusCode() == 200) {
      System.debug('Exitoso '+ res);

// checking the result
      Event acc = new Event(Id='00US00000014KqmMAE');
     acc.Description = ' Created '+datetime.now()+'  '+res.getBody()+' inicio '+fecha_inicio+'  fin '+fecha_fin+' lat '+latitud+' long '+Longitud ;

       try {
               update acc;
      
               
            } catch (DmlException e) {
                //Assert Error Message
                System.assert( e.getMessage().contains('Update error'),
                e.getMessage());
            }//catch
      


    } else {
      System.debug('Callout failed: ' + res);
// checking the result      
      Event acc = new Event(Id='00US00000014KqmMAE');
      acc.Description = 'Malo '+res.getBody();

       try {
               update acc;
            } catch (DmlException e) {
                //Assert Error Message
                System.assert( e.getMessage().contains('Update error'),
                e.getMessage());
            }//catch
      
    }
    
 
    

    }///api Call
    
    
}///class

 

/**************************************test mehotd*****************************/

 

 

 

@isTest
private class TestApiCall
 {
  //Added for security review
 
   public static testMethod void TestAPICall() {
    
        // TO DO: implement unit test

 

     Datetime fecha_inicio = datetime.now();
     Datetime fecha_fin = datetime.now();
     string Event_Id = '00UA00000041osdMAA';
     string account_Id = '001A000000LKjdeIAD';
     
     APICall.APICall_Request(fecha_inicio, fecha_fin, Event_Id, account_Id); /// after add this I increase the coverage from 53 % to 67%
     
     List<Account> b = [Select latitud__c, Longitud__c, Id From Account Where Id='001A000000LKjgIIAT'];

    string latitud = b[0].latitud__c;
    string Longitud = b[0].Longitud__c;
     
     List<Event> t = [Select EndDateTime, StartDateTime, Id, WhatId From Event Where Id='00UA00000041oscMAA'];


    Datetime fecha_fint    = t[0].EndDateTime;
    Datetime fecha_iniciot = t[0].StartDateTime;
    string Event_Idt= t[0].Id;
    string account_Idt = t[0].WhatId;


     
    APICall.APICall_Request(fecha_iniciot, fecha_fint, Event_Idt, account_Id); //adding this new line still have 67%
     
        
           Account acc2 = new Account(Id='001A000000LKjgIIAT');
           acc2.name = 'ANVA CELULAR, C.A.';
           acc2.latitud__c = '654897' ;
            acc2.Longitud__c = '98732100' ;
            
            acc2.Categoria__c = 'Uno (1)';
            acc2.Estatus__c = 'Operativo';
            acc2.Region__c ='GRAN CARACAS';
            acc2.Zona__c = 'ZONA METROPOLITANA';
            acc2.Tipo__c = 'AA - Agente Autorizado';
            
            try {
               update acc2;
            } catch (DmlException e) {
                //Assert Error Message
                System.assert( e.getMessage().contains('Update error'),
                e.getMessage());
            }//catch
 
        
        acc2 = [Select name from Account where Id=:acc2.Id];  
        System.debug('Nombre: ' + acc2.name);
        System.assertEquals('ANVA CELULAR, C.A.', acc2.name);
        
        
         

        
          Account acc3 = new Account(Id='001A000000P2qYeIAJ');
           acc3.name = 'EQUIPOS ELECTRONICOS GLENOS, C.A.';
           acc3.latitud__c = '654897' ;
            acc3.Longitud__c = '98732100' ;
            
            acc3.Categoria__c = 'Uno (1)';
            acc3.Estatus__c = 'Operativo';
            acc3.Region__c ='GRAN CARACAS';
            acc3.Zona__c = 'ZONA METROPOLITANA';
            acc3.Tipo__c = 'AA - Agente Autorizado';
            update acc3;
        
        acc3 = [Select name from Account where Id=:acc3.Id];  
        System.debug('Nombre: ' + acc3.name);
        System.assertEquals('EQUIPOS ELECTRONICOS GLENOS, C.A.', acc3.name);


     
    
    }
    
    }//test class

 

Thanks in Advance

 

 

Dears

 

I create visual force page that connect to google map and display it in account module, the map works perfect in firefox, but when I run it in Internet Explores i got a message inform that "This page ha content that won´t be sent using a secure HTTPS" (message summary) and I have two options "Yes" or "No" when I click in Yes the map is not displayed, when I click "No" the map is displayed but in a wrong latitude, longitude address, how may I solve this issue with internet exploere? Below the code:

 

 

<apex:page standardController="Account" extensions="lat_lon_GoogleMap"    >
 

 <html>
  <head>
    <script type="text/javascript"
            src="http://www.google.com/jsapi?key=ABQIAAAAe2NFOp1WA-r3hEnPeArUrBST0mNpJvtWvmgvEdrgGXs5szHHahQf0jJpikHErriZM-CeKx3OJZgXvQ"></script>
    <script type="text/javascript">
       
    var geocoder;
    var address;
    //standardController="Account" extensions="lat_lon_GoogleMap"
      google.load("maps", "2");
      google.load("search", "1");

      // Call this function when the page has been loaded
      function initialize() {

 

/****display map in div*****/

        var map = new google.maps.Map2(document.getElementById("map"));
/**** in my opinion only display the map until this section*******/    

 

 

/**** Thsi section is not displayed, the address*******/

             map.setCenter(new google.maps.LatLng(10.4974997, -66.8445959), 15);
              map.openInfoWindow(map.getCenter(),
                       document.createTextNode("Please complete info"));//msj

        
        map.setMapType(G_HYBRID_MAP);//G_HYBRID_MAP, G_SATELLITE_MAP
        map.setUIToDefault();
        GEvent.addListener(map, "click", getAddress);
      geocoder = new GClientGeocoder();

      }
        function getAddress(overlay, latlng) {

      if (latlng != null) {
        address = latlng;
        geocoder.getLocations(latlng, showAddress);
      }
    }
    
     function showAddress(response) {
                
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                             place.Point.coordinates[0]);
         
              
 

      if (!response || response.Status.code != 200) {

        alert("Por favor contacte al administrador, no se guardaron las Coordenadas, Status Code:" + response.Status.code);
      } else {
        
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
 
 


        }
    }
    
 
   
      
      google.setOnLoadCallback(initialize);
      }//si no tiene lat
      
  
    </script>

  </head>
 
  <body>
 <apex:form id="form1">

 <apex:pageMessages id="error"/>

    <!--   Display info-->


 </apex:form>
<!--   Display map-->
 <div id="map"  style="width: 950px; height: 700px">    </div>
 
 
  </body>

</html>


   </apex:page>

 

 

 

 

 

 

Thanks in advances

  • October 01, 2010
  • Like
  • 0

Dears

 

I would like to know how to display a value in any field of my form Contact. I get the value from a JavaScript function after that I need to send the value and  dislay in the field Phone Number (example) module Contact.

 

Below  the code

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>

   <script type="text/javascript">

 


function test(){

var  abc;

                  //this part of the code work but is not what I want.

               document.getElementById("lat").value=  abc   --> "Value get form another Javascript function";

 

// I want to display the value of "var  abc"  in the field phone numbe rof module contact

 

}

 

</script>      
  </head>
  <body  style="font-family: Arial;border: 0 none;">

    <div id="map_canvas" style="width: 700px; height: 400px">

<input name="lat" id="lat" type="text" readOnly="true" />

 

<!--  Display info  -->

</div>
  </body>
</html>

Dears

 

Please could you help me to parse a XML code that contain the latitude and longitude of address? Below the XML code I try with the manual but I has for soap and the another example is too simple to parse this complicated XML of google.

 

I want to take the value of latitude and longitude.

 

Thanks in advances

 

<GeocodeResponse> 
 
<status>OK</status>
 
<result>
 
<type>street_address</type>
 
<formatted_address>1600 Amphi Pkwy, Mountain, CA 94043, USA</formatted_address>
 
<address_component>
   
<long_name>1600</long_name>
   
<short_name>1600</short_name>
   
<type>street_number</type>
 
</address_component>
 
<address_component>
   
<long_name>Amphitheatre Pkwy</long_name>
   
<short_name>Amphitheatre Pkwy</short_name>
   
<type>route</type>
 
</address_component>
 
<address_component>
   
<long_name>Mountain View</long_name>
   
<short_name>Mountain View</short_name>
   
<type>locality</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>San Jose</long_name>
   
<short_name>San Jose</short_name>
   
<type>administrative_area_level_3</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>Santa Clara</long_name>
   
<short_name>Santa Clara</short_name>
   
<type>administrative_area_level_2</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>California</long_name>
   
<short_name>CA</short_name>
   
<type>administrative_area_level_1</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>United States</long_name>
   
<short_name>US</short_name>
   
<type>country</type>
   
<type>political</type>
 
</address_component>
 
<address_component>
   
<long_name>94043</long_name>
   
<short_name>94043</short_name>
   
<type>postal_code</type>
 
</address_component>
 
<geometry>
   
<location>
   
<lat>37.4217550</lat>
   
<lng>-122.0846330</lng>
   
</location>
   
<location_type>ROOFTOP</location_type>
   
<viewport>
   
<southwest>
     
<lat>37.4188514</lat>
     
<lng>-122.0874526</lng>
   
</southwest>
   
<northeast>
     
<lat>37.4251466</lat>
     
<lng>-122.0811574</lng>
   
</northeast>
   
</viewport>
 
</geometry>
 
</result>
</GeocodeResponse>
  • April 27, 2010
  • Like
  • 0

Hello,

 

I'm simply looking for how to retrieve the current API calls of the org through Apex but don't find anything similar in the documentation. I know that we can find this information in the company profile but I would like to get this information in my trigger/class in order to prevent future call according to my own limit (some calls are very important while other could wait 24 hours). Does anyone know how to get this information ?

 

Thank you !

Dears

 

I need to add a page in contact module that show a static google map, this map will be created after send via URL some data needed by google to create the map.

 

Below the link:

 

http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap
&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318
&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false

 

This is a test link I will pass the address of contac for each user.

 

Best Regards

  • April 22, 2010
  • Like
  • 0

Dears

 

Please could you help me to get the correct code to the below  issue? I need to take the value of the field name or address and save into a string value, after that these strings I will send via XML to external server.

 

Account a = [SELECT Name FROM Account WHERE Name = 'Foo' LIMIT 1];
String s = a.Name;// I can save it, but when I run the application I get another error.
String c = Account.Name;//second option I get the error "Illegal assignment from Schema.SObjectField to String".
  • April 21, 2010
  • Like
  • 0

Hi, Please could you help me take one value from a field of object contact? This is my code, it is not working properly(the result is null), the ID 0033000000bOWgWAAW exist and the name of the field is correct, I want to take a value of field address and send it via url to external web service.

 

    contact cont = new contact(Id = '0033000000bOWgWAAW');
    string name2 = cont.FirstName; /// the result is null

 

All this code is inside a class or inside a trigger.

 

I thing this is a simple thing but I am stuck. (I check the book "apex code developer's guide Version 18").

 

Thanks in advance

  • April 13, 2010
  • Like
  • 0

I am declaring a String variable = to an existing Case field of Text data type in a Trigger. Why am I getting this Compile Error? 

 

"Illegal assignment from Schema.SObjectField to String"