• karimulla testing
  • NEWBIE
  • 70 Points
  • Member since 2018

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 13
    Replies
public class SendAccountUsingRestApi {
String clientId='3MVG9676d8..z.hDcPLFoiqi2ctTtDy_x5RsHkuU9cjgz2WNbR6qyyrT8Oab.zpRK9whew.gYjriuYbDx41pikpc';
    String clientsecret='608669815107085755889';
    string username='ddddd@trailhead.com';
    String password='TEaST@123';
    String accesstoken_url='https://login.salesforce.com/services/oauth2/token';
    String authurl='https://login.salesforce.com/services/oauth2/authorize';
  public class deserializeResponse{
      public String id;
      public String access_token;   
   }
    public String ReturnAccessToken(SendAccountUsingRestApi Acc){
        String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password; // String reqbody='{"grant_type":"password","client_id":clientId,"client_secret":clientSecret,"username":username,"password":password}';
        Http h= new Http();
        HttpRequest req= new HttpRequest();
        req.setBody(reqbody);
        req.setMethod('POST');
       
        req.setEndpoint('https://ap4.salesforce.com/services/oauth2/token'); //Change "ap4" in url to your Target Org Instance 
        HttpResponse res=h.send(req);
        System.debug(res.getBody()+'###1203res');
        deserializeResponse resp1=(deserializeResponse)JSON.deserialize(res.getBody(),deserializeResponse.class);
        System.debug(resp1+'###1203deserializeresponse');
        return resp1.access_token;
    }

   @future(callout=true)
    public static void createAccount(String Accname){
        SendAccountUsingRestApi acc1= new SendAccountUsingRestApi();
        String accessToken=acc1.ReturnAccessToken(acc1);
        System.debug(accessToken+'###0012');
        if(accessToken!=null){
            String endPoint='https://ap5.salesforce.com/services/data/v32.0/sobjects/Account'; //Change "ap4" in url to your Target Org Instance 
            String jsonstr='{"Name":"'+ Accname +'"}';
            Http h2= new Http();
            HttpRequest req2= new HttpRequest();
            req2.setHeader('Authorization','Bearer ' + accessToken);
            req2.setHeader('Content-Type','application/json');
            req2.setHeader('accept','application/json');
            req2.setBody(jsonstr);
            req2.setMethod('POST');
            req2.setEndpoint(endPoint);
            HttpResponse res2=h2.send(req2);
            System.debug(res2+'###1203createresp');
            deserializeResponse deresp2=(deserializeResponse)System.JSON.deserialize(res2.getBody(),deserializeResponse.class);
            System.debug('###1203createdeser'+deresp2);
        }
    }
    }

this code is saved .. bt while creating the trigger on account it is showing an error with the below code
trigger SendAccount on Account (after insert) {
    for(Account a:Trigger.new){
        SendAccountUsingRestApi.createAccount(a.name, a.Id);
    }
}
error is 
Error	Error: Compile Error: Method does not exist or incorrect signature: void createAccount(String, Id) from the type SendAccountUsingRestApi at line 3 column 33
please solve this if possible 
 thanks
An application is developed in dotnet crm application, in the registration page,  for salesforce existing users, they have to provide the button of login with salesforce ,once clicking on button and entering his credentials of username and password and login if it gets validates, then automatically for the dotnetcrm application, all necessary data should be fetched form salesforce account and an new user is created in the dotnetcrm application,.
 it is not for the single org, it should be applicable to all the salesforce users , globally.
note: it is for the global users of salesforce , if it is  a single org, we can create a connected app or cilent id or client secert, but it is for the multiple orgs, how can it get achieved form dotnet team  
https://www.merlinguides.com/login
once login with salesforce and validate the data, users personal data is fectched from salesforce and created a new user of merlinguides, i need a same scenario where external application developed in dotnet, once user login with salesforce  credentials, the data like firstname, lastname , company etc  should be fectched as the link shared above.. in need the same scenario from the donet side for gloabal users.
thanks 
i have a small doudt how it can be done from salesforce , one of the application is built in donet,in that application, they will provide an button of login with salesforce for salesforce  existing users, once he enter the credentials and login, it should be validate the account, once it got sucessfully validated, an user will be created in that dotnet application. is it possible to validate, the username and password provided is valid or not.
 how it can be acheived????
 if the callout is done the data is stored  and retrieved any time by use of  caching, now, the  requirement is , cached data should be  automatically get cleared totally, when the user logouts from the application, is this possible in the  session caching ??? 
note: Time limit  for the caching , is not taken into the consideration here...only if user gets logouts the cached data should be cleared, again if the user logged in the callout made and data should be stored in cached..
how may types of the authnetication types for making the rest callouts  to dotnet by using the salesforce ,..and connetiing to the localserver 
As local server is exposed to public server by using natting by the network adminstrators, as it is tunneled/exposed to public , salesforce cant able to make the callouts  , do you have any idea how it can be acheived????
Hi Everyone
 
Can we hit a local/private server using IP address with HTTP request in Salesforce ?? or the server should always be public....
can we access a private IP address of local host/server using the HTTP methods that salesforce.com provides. how to hit the local server...

I have make the callout which was written in .Net (hosted on localserver) which will get the data from stored procedure in SQL.

When i was trying to get the data from SQL to Salesforce , i was able to get the data when i was using the advanced rest tool.
But when i tried in salesforce callouts http methods  with end point url after  setting remotesitesetting , i could not get the  data.User-added image  it gives me an error of '503 service unavailable'.

,when i tried to execute a block of code in Salesforce, i  made callout to  the .Net webservice  file  to test the data, i got an error 'Server unavailable,status code = 503'.

My another important question is ''If the Webservice is hosted on the local or intranet, will the salesforce API (which is on the cloud) able to access that webservice
 
 
Thanx in advance
hi..
i had passed the url in remotesite settings and after that in anonymous window:

  Http http = new Http();
                     HttpRequest request = new HttpRequest();
              request.setEndpoint('http://www.XXXXXXXX.com/api/GetCountryDetails');
              request.setMethod('GET');
        HttpResponse response = http.send(request);
        // Parse the JSON response
        if (response.getStatusCode() != 404) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
        }
... Actually we are trying to restcallout form salesforce application to other dotnet(.net) application which is in developing in local server or hosted in the local server  ... iam getting an  error as shown
User-added image
how to make the callout will the other application is in localserver...any idea will be appreciated....
I need to open a visualforce page in a same window tab and same window in salesforce org with header and sidebar ,iam using <apex:comandbutton  (login)>..While I click the login and pass the url then,the page is opened in a same tab in salesforce org within  header and sidebar.....how can i do it.help me to find a solution.
 
hi all thanks in advance.......anybody working in encryption and decryption in salesforce and other dotnet external application :
 
apexclass:
public with sharing class Security {
  /*
    key length depends of ALGORITHM_NAME! 
    In case, it uses AES256 so we need to use 32 bytes key must.
  */    
  public static final String MY_KEY = '12345678901234567890123456789012'; // it always must  be 32bytes 
  public static final String MY_IV = 'HR$2pIjHR$2pIj12'; //it always will be 16 bytes
  public static final String ALGORITHM_NAME = 'AES256';
  public static Blob encrypt(String valueToEncrypt){
    Blob key = Blob.valueOf(MY_KEY);
    Blob iv = Blob.valueOf(MY_IV);
    Blob data = Blob.valueOf(valueToEncrypt);
    return Crypto.encrypt(ALGORITHM_NAME, key, iv, data);
  }
  public static Blob decrypt(Blob encryptedData){
    Blob key = Blob.valueOf(MY_KEY);
    Blob iv = Blob.valueOf(MY_IV);
    return Crypto.decrypt(ALGORITHM_NAME, key, iv, encryptedData);
  }
   
}
 
//--------------open the anonymous window in developer console-----------------------//
Blob encryptedData = Security.encrypt('India');
String base64Data = EncodingUtil.base64Encode(encryptedData);
System.debug('encryptedData: ' + base64Data);
System.debug('iv: ' + EncodingUtil.base64Encode(Blob.valueOf(Security.MY_IV)));
System.debug('key: ' + EncodingUtil.base64Encode(Blob.valueOf(Security.MY_KEY)));
Blob decryptedData = Security.decrypt(encryptedData);
System.debug('decryptedData: ' + decryptedData.toString());
 
 
//------------------------requirement is here------------------------//
We have used a salesforce method  key sizeof AES256 and keyvalue as '12345678901234567890123456789012'  32bytes for encrypting the login credentials
But in .net application for encrypting, they have used keysize of AES256 and keyvalue as “MARKETING” which is 9bytes.
we had used the same keyvalue“MARKETING”,for encryption but it is showing an error that keyvalue must be of 32bytes..
 
 
 
AFTER ENCRYPTION INDIA THE ENCRPTED VALUE SHOULD BE :
k+aPFgavOKqygOIsLhf8EQ==
For 'India'
 
////////////////////----dotnet code as shown below----//////////////////
private static string Salt = "MarketingInc";
        private static string HashAlgorithm = "SHA1";
        private static int PasswordIterations = 2;
        private static string InitialVector = "HR$2pIjHR$2pIj12";
        private static int KeySize = 256;
 
 
public static string EncryptText(string toBeEncrypted, string password)
        {
            string result;
            try
            {
                if (string.IsNullOrEmpty(toBeEncrypted))
                {
                    result = "";
                }
                else
                {
                    byte[] bytes = System.Text.Encoding.UTF8.GetBytes(toBeEncrypted);
                    byte[] bytes2 = System.Text.Encoding.UTF8.GetBytes(password);
                    byte[] inArray = EncryptDecrypt.AES_Encrypt(bytes, bytes2);
                    string text = System.Convert.ToBase64String(inArray);
                    result = text;
                }
            }
            catch (System.Exception)
            {
                result = "";
            }
            return result;
        }
        public static string DecryptText(string toBeDecrypted, string password)
        {
            string result;
            try
            {
                if (string.IsNullOrEmpty(toBeDecrypted))
                {
                    result = "";
                }
                else
                {
                    byte[] cipherTextBytes = System.Convert.FromBase64String(toBeDecrypted);
                    byte[] bytes = System.Text.Encoding.UTF8.GetBytes(password);
                    byte[] bytes2 = EncryptDecrypt.AES_Decrypt(cipherTextBytes, bytes);
                    string @string = System.Text.Encoding.UTF8.GetString(bytes2);
                    result = @string;
                }
            }
            catch (System.Exception)
            {
                result = "";
            }
            return result;
        }


solve the problem
we had created a managed and unmanaged application in salesforce..we should create a link or url separtely that after clicking on it is redirected to the salesfroce page and after logging into it , the application should automatically installed into it
when clicking on the link or button ,it should redirect to the  salesforce application of the users and install the application of we created in salesforce ..how is it possible...
(Encrpting with key "1234567890123456" it is getting encrpted):
Blob key = Blob.valueOf('1234567890123456');  //WITH 16BYTES
String myStringToEncrypt = 'This is my String....'
Blob myBlobData = Blob.valueOf(myStringToEncrypt)
Blob myEncryptedString = Crypto.encryptWithManagedIV('AES256', key, myBlobData)

(Encrpting with key "INDIA" it is  not getting encrpted)  :
SHOWING ERROR:  Invalid private key. Must be 16 bytes.

Blob key = Blob.valueOf('INDIA'); //
String myStringToEncrypt = 'This is my String....'
Blob myBlobData = Blob.valueOf(myStringToEncrypt)
Blob myEncryptedString = Crypto.encryptWithManagedIV('AES256', key, myBlobData)

/// I KNOW THAT IT SHOULD BE 16 BYTES REQUIRED
//////bt in .net application they used the key "INDIA" and encrpted with 'AES256'.. need samekey "INDIA"   in salesforce ...MAY I GET THE SOLUTION
(Encrpting with key "1234567890123456" it is getting encrpted):
Blob key = Blob.valueOf('1234567890123456');  //WITH 16BYTES
String myStringToEncrypt = 'This is my String....'
Blob myBlobData = Blob.valueOf(myStringToEncrypt)
Blob myEncryptedString = Crypto.encryptWithManagedIV('AES256', key, myBlobData)

(Encrpting with key "INDIA" it is  not getting encrpted)  :
SHOWING ERROR: 
 Invalid private key. Must be 16 bytes.

Blob key = Blob.valueOf('INDIA'); //
String myStringToEncrypt = 'This is my String....'
Blob myBlobData = Blob.valueOf(myStringToEncrypt)
Blob myEncryptedString = Crypto.encryptWithManagedIV('AES256', key, myBlobData)

/// I KNOW THAT IT SHOULD BE 16 BYTES REQUIRED
//////bt in .net application they used the key "INDIA" and encrpted with 'AES256'.. need samekey "INDIA"   in salesforce ...MAY I GET THE SOLUTION
hi i had actually created the apexclass:
  

public class tpc{

    public PageReference ClickHere(){

     

        PageReference pr = new PageReference('https://www.c*******k*ar*k.ca/account/sign-in');   //this is third party application 
        pr.setRedirect(true);
        return pr;
    } 

}
 

 visualforce page :
<apex:page Controller="tpc" sidebar="false" showHeader="false">
<apex:form >
<html> 
<center><h>click  to direct login into ch*** p** application with out providing username and password</h></center>
</html>
<div align="center" draggable="false" >
<apex:commandButton action="{!ClickHere}" value="Click Here" />
</div>
</apex:form>
</apex:page>

After login into salesforce i had created a visualforce tab as "login" and 
on clicking the " click here " button provided in it .. it is redirecting to the url provided at apexclass i.e (https://www.c*******k*ar*k.ca/account/sign-in) we should provide username and password in this application and login into it..
//////////
my question is when you click on the "clickHere " button it should automatically redirect  to main page without asking or providing the username and password  or credentials every time.. is this possible here in salesforce ..... 
any other procedurce or links or pdf or codes how can we do it ... please provide your valuable coments.....

i hope i vill receive more commets,, it will be helpful and appreciated
on clicking the link...it should redirect to other .net org directly , without  entering the logincredentials of .net.....how it is possible
while saving 11th  record it should show an error while saving that limit had exceeded
Hi All,

I have tried to pass user name and password  site url, is look like the below.
https://www.salesforce.com/login.jsp?pw=12345&un=sourcetesting@gmail.com



This is working fine ,
but i want to encrypt the username and password while passing in url for security reasons and also want to decript username and password in salesforce side

In my site URL i am using the standard page, is 'login'. is this possible to decrypt the username and password from 'login' page

Over all my requirement is, we have one link. Link contains the above url. User can able to login to  by clicking the link without enter the credentials (Custom SSO). In this we want to make the user name and password in the form of encrypt or hide.

Please give me any solutions or work arounds for this
public class SendAccountUsingRestApi {
String clientId='3MVG9676d8..z.hDcPLFoiqi2ctTtDy_x5RsHkuU9cjgz2WNbR6qyyrT8Oab.zpRK9whew.gYjriuYbDx41pikpc';
    String clientsecret='608669815107085755889';
    string username='ddddd@trailhead.com';
    String password='TEaST@123';
    String accesstoken_url='https://login.salesforce.com/services/oauth2/token';
    String authurl='https://login.salesforce.com/services/oauth2/authorize';
  public class deserializeResponse{
      public String id;
      public String access_token;   
   }
    public String ReturnAccessToken(SendAccountUsingRestApi Acc){
        String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password; // String reqbody='{"grant_type":"password","client_id":clientId,"client_secret":clientSecret,"username":username,"password":password}';
        Http h= new Http();
        HttpRequest req= new HttpRequest();
        req.setBody(reqbody);
        req.setMethod('POST');
       
        req.setEndpoint('https://ap4.salesforce.com/services/oauth2/token'); //Change "ap4" in url to your Target Org Instance 
        HttpResponse res=h.send(req);
        System.debug(res.getBody()+'###1203res');
        deserializeResponse resp1=(deserializeResponse)JSON.deserialize(res.getBody(),deserializeResponse.class);
        System.debug(resp1+'###1203deserializeresponse');
        return resp1.access_token;
    }

   @future(callout=true)
    public static void createAccount(String Accname){
        SendAccountUsingRestApi acc1= new SendAccountUsingRestApi();
        String accessToken=acc1.ReturnAccessToken(acc1);
        System.debug(accessToken+'###0012');
        if(accessToken!=null){
            String endPoint='https://ap5.salesforce.com/services/data/v32.0/sobjects/Account'; //Change "ap4" in url to your Target Org Instance 
            String jsonstr='{"Name":"'+ Accname +'"}';
            Http h2= new Http();
            HttpRequest req2= new HttpRequest();
            req2.setHeader('Authorization','Bearer ' + accessToken);
            req2.setHeader('Content-Type','application/json');
            req2.setHeader('accept','application/json');
            req2.setBody(jsonstr);
            req2.setMethod('POST');
            req2.setEndpoint(endPoint);
            HttpResponse res2=h2.send(req2);
            System.debug(res2+'###1203createresp');
            deserializeResponse deresp2=(deserializeResponse)System.JSON.deserialize(res2.getBody(),deserializeResponse.class);
            System.debug('###1203createdeser'+deresp2);
        }
    }
    }

this code is saved .. bt while creating the trigger on account it is showing an error with the below code
trigger SendAccount on Account (after insert) {
    for(Account a:Trigger.new){
        SendAccountUsingRestApi.createAccount(a.name, a.Id);
    }
}
error is 
Error	Error: Compile Error: Method does not exist or incorrect signature: void createAccount(String, Id) from the type SendAccountUsingRestApi at line 3 column 33
please solve this if possible 
 thanks
As local server is exposed to public server by using natting by the network adminstrators, as it is tunneled/exposed to public , salesforce cant able to make the callouts  , do you have any idea how it can be acheived????
on clicking the link...it should redirect to other .net org directly , without  entering the logincredentials of .net.....how it is possible
while saving 11th  record it should show an error while saving that limit had exceeded
Hi All,

I have tried to pass user name and password  site url, is look like the below.
https://www.salesforce.com/login.jsp?pw=12345&un=sourcetesting@gmail.com



This is working fine ,
but i want to encrypt the username and password while passing in url for security reasons and also want to decript username and password in salesforce side

In my site URL i am using the standard page, is 'login'. is this possible to decrypt the username and password from 'login' page

Over all my requirement is, we have one link. Link contains the above url. User can able to login to  by clicking the link without enter the credentials (Custom SSO). In this we want to make the user name and password in the form of encrypt or hide.

Please give me any solutions or work arounds for this
 my requirement is like this::::::
 costumer  will login in with the salesforce credentials and perform some operations then after saving data it should not be save in salesforce database....
is it possible ..please let me know....send me the links and infromation about how to store data in sql server
/*********************************************************************

* Description - Apex REST service with GET and POST methods

* Author - AP

<u>Json format</u>

{

"name" : "Akash",

"phone" : "8826031286",

"website" : "www.akashmishra.co.in"

}

***********************************************************************/

@RestResource(urlMapping='/v3/accounts/*')

global with sharing class REST_AccountService_V4 {

@HttpPost

global static AccountWrapper doPost(String name, String phone, String website) {

RestRequest req = RestContext.request;

RestResponse res = RestContext.response;

AccountWrapper response = new AccountWrapper();

Account acct = new Account();

acct.Name = name;

acct.Phone = phone;

acct.Website = website;

insert acct;

response.acctList.add(acct);

response.status = 'Success';

response.message = 'Your Account was created successfully.';

return response;

}

@HttpGet

global static AccountWrapper doGet() {

RestRequest req = RestContext.request;

RestResponse res = RestContext.response;

AccountWrapper response = new AccountWrapper();

String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);

if(doSearch(accountId))

{

searchAccounts(req, res, response);

}

else

{

findAccount(res, response, accountId);

}

return response;

}

// If the item to the right of the last forward slash is "accounts", the request went to

//v3/accounts?Name=Akash

// Else the request went to v3/accounts/&lt;something&gt;, which is not a search, but a specific

//entity

private static boolean doSearch(String accountId) {

if(accountId == 'accounts') {

return true;

}

return false;

}

//If the request came to /v3/accounts, then we want to execute a search

Public static void searchAccounts(RestRequest req, RestResponse res,

AccountWrapper response) {

//Use the RestRequest's params to fetch the Name parameter

String searchTerm = req.params.get('Name');

if(searchTerm == null || searchTerm == '') {

response.status = 'Error';

response.message = 'You must provide a Name for your search term.';

res.StatusCode = 400;

}

else {

String searchText = '%'+searchTerm+'%';

List&lt;Account&gt; searchResults =

[SELECT Id, Name, Phone, Website FROM Account WHERE Name LIKE : searchText];

if(searchResults != null &amp;&amp; searchResults.size() &gt; 0) {

response.acctList = searchResults;

response.status = 'Success';

response.message = searchResults.size()

+ ' Accounts were found that matched your search term.';

}

else {

response.status = 'Error';

response.message =

'No Accounts were found based on that Name, please search again.';

}

}

}

&nbsp;

//If the request came to v3/accounts/sometext then we want

//to find a specific account

Public static void findAccount(RestResponse res, AccountWrapper response,

String accountId) {

// Provided we recevied an External Id, perform the search and return the results

if(accountId != null &amp;&amp; accountId != '') {

List&lt;Account&gt; result = [SELECT Id, Name, Phone, Website FROM Account

WHERE External_Id__c =: accountId];

if(result != null &amp;&amp; result.size() &gt; 0) {

response.acctList.add(result[0]);

response.status = 'Success';

}

else {

response.status = 'Error';

response.message = 'This account could not be found, please try again.';

res.StatusCode = 404;

}

}

// If the request came to /v3/accounts/ (without an Account Id),

//return an error

else {

response.status = 'Error';

response.message = 'You must specify an External Id.';

res.StatusCode = 400;

}

}

global class AccountWrapper {

public List&lt;Account&gt; acctList;

public String status;

public String message;

public AccountWrapper(){

acctList = new List&lt;Account&gt;();

}

}

}



can anybody resolve this issue
 
Hello,

I have embedded a dashboard into my custom object, however it is not actually 'linked' to the object.  I have based the dashboard on a formula that should tell us what the health of the customers location is, however all it is doing is displaying whatever the original dashboard displayed, it's not being customized to match the unique location that it is being displayed in.

I am fairly new with VisualForce still, does anyone have any ideas on how I can modify this embedded page so that the dashboard is live and linked to the individual site that it is being displayed in?  

Please let me know if that makes sense, thank you so much!

User-added image
Hi Guys,

Am posting json text data from google advanced rest api client,but it throws error like :503 Service Unavailable

It is the Data am giving : {"rewardamnt"="15000","active_or_inactive": "true"}

Content-Type :application/json

MY URL :https://quinnoxspm-developer-edition.na15.force.com/WebMethods/services/apexrest/RewardCreation

https://quinnoxspm-developer-edition.na15.force.com -->Force.com site URL

WebMethods-->Site Name

services/apexrest-->Common for apex rest resource

RewardCreation--->My controller having urlmapping.

I'm looking for a solution to call an application which is running on my local system. My requirement is -

1. On click on a tab (for example tab name is : My External App) from force site, it should call http://localhost:8080/myapp

2. On clicking on tab from #1, I want to pass parameters on http request header & URL parameter. For example, I want to pass logged in user id from Salesforce to my local application like http://localhost:8080/myapp?parm=userid

3. After I click on tab, my external application page should open within Salesforce in an IFRAME or some other way(I'm not aware of some other way).

 

I'm very new to Salesforce, Kindly let me know how to proceed on this. Any tutorial or guide or suggestion is highly appreciated. 

 

 

 

 

I have the following code for pulling up driving directions from SalesForce. Works amazingly well as long as the address is on one line. When it's a two-line address, none of the script will load. I've tried putting the variable into a try/catch rule, but that doesn't solve the problem. Advice?

 

 

 

<apex:page standardController="Account" showHeader="false" sidebar="false" standardstylesheets="false">
<script>

// SOFTWARE BUG!!! MULTI-LINE ADDRESS AND PAGE LOADS W/O JAVASCRIPT!

var currentLocation;

function getLocation()
  {
    navigator.geolocation.getCurrentPosition(showPosition);
  }

function showPosition(position)
  {

try {

    var address = '{!Account.BillingStreet}' + '{!Account.BillingCity},' + '{!Account.BillingState}' + '{!Account.BillingPostalCode}';
    var destination = address.split(' ').join('+');
}
catch(err)
{

    alert('Street address must be on one line to use this function.');
    window.close();
    
}

  currentLocation = position.coords.latitude + ',' + position.coords.longitude;
  
  if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/iPod/i)))
    {
        var URL = 'http://maps.apple.com/?saddr=' + currentLocation + '&daddr=' + destination;
        window.open(URL,'_parent');
    }
  else
    {
        var URL = 'https://maps.google.com/maps?saddr=' + currentLocation + '&daddr=' + destination;
        window.open(URL,'_parent');
    }
  }
function init()
  {
    document.write('<div style="position:absolute;top:50%;left:50%;">loading...</div>');
    getLocation();
  }

window.onload = new function() { init(); };


</script>

</apex:page>