You need to sign in to do that
Don't have an account?

Save from VF page (javascript values) to object Account (custom field)
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
I don't know whether I completely understood your question. However one of the following solutions could help you.
1)If the account id is available in your URL, you can retrieve it to your javascript code by using following syntax.
{!$currentPage.parameters.id}
Ex:- alert('{!$currentPage.parameters.id}');
2) You can't use two controllers but you can use your 'lat_lon_GoogleMap' class as an extension.
<apex:page standardController="Account" extensions="lat_lon_GoogleMap">
Remember in order to use as above, your controller class(lat_lon_GoogleMap) should contains the following constructor.
public lat_lon_GoogleMap(ApexPages.StandardController controller) {}
3)If the account id is available in your URL, you can retrieve it to your controller class(lat_lon_GoogleMap) by using following syntax.
String accountId = ApexPages.currentPage().getParameters().get('id');
All Answers
I don't know whether I completely understood your question. However one of the following solutions could help you.
1)If the account id is available in your URL, you can retrieve it to your javascript code by using following syntax.
{!$currentPage.parameters.id}
Ex:- alert('{!$currentPage.parameters.id}');
2) You can't use two controllers but you can use your 'lat_lon_GoogleMap' class as an extension.
<apex:page standardController="Account" extensions="lat_lon_GoogleMap">
Remember in order to use as above, your controller class(lat_lon_GoogleMap) should contains the following constructor.
public lat_lon_GoogleMap(ApexPages.StandardController controller) {}
3)If the account id is available in your URL, you can retrieve it to your controller class(lat_lon_GoogleMap) by using following syntax.
String accountId = ApexPages.currentPage().getParameters().get('id');
Use the sample code given below to get AccountId in controller when you are using standard controller with extension :
Id aid = ApexPages.currentPage().getParameters().get('id');
Account acc = [select name from Account where id =:id];
Hope this helps.