• Kalle Kalif
  • NEWBIE
  • 55 Points
  • Member since 2011

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 20
    Replies

I have a inbound email service handling .txt attachments coming from many different users around my organisation. All emails are sent using MS outlook.

 

Sometimes the text attachment will be recognized as binary attachment, and consequently discarded. In one case I am looking at now, if i forward the troublesome email with the attachment, it will always detect the attachment as binary. However if I store the attachment on my HDD, and create a new email with this file and send it, it will work. 

 

Any thoughts are highly appreciated!

We need to put two dashboards together in one email, and send to a number of addresses that are contained in a custom field in a custom object. 

 

I am somewhat versed with apex and visualforce so if that is the way to go I guess we can manage, but I really dont know where to start?

Good day esteemed experts,

 

I am unable to increase the test coverage of my email-recieving class above ~50%.

 

Email Class:

 

global class DailyRecieve implements Messaging.InboundEmailHandler
{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,Messaging.InboundEnvelope envelope){
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

source=email.plaintextbody;

//prepare dummy list for use if data source does not contain certain fields
string[] dummy=new List<String> ();
dummy.add('');
dummy.add('');

//Retrieve Truck name from License number
string[] Licenseno = source.split('<License>',3);
string License= Licenseno[1].trim().substring(0);
Truck__c[] Truck = [select Name from Truck__c where License_no__c = :License Limit 1];


//Retrieve data
string[] OBJECT_ID=((source.contains('<OBJECT_ID>') == false)? dummy :source.split('<OBJECT_ID>',3));
string[] OPERATION_CODE=((source.contains('<OPERATION_CODE>') == false)? dummy :source.split('<OPERATION_CODE>',3));
string[] REPORT_VERSION=((source.contains('<REPORT_VERSION>') == false)? dummy :source.split('<REPORT_VERSION>',3));
string[] REPORT_NOON=((source.contains('<REPORT_NOON>') == false)? dummy :source.split('<REPORT_NOON>',3));
string[] REPORT_OFFHIRE=((source.contains('<REPORT_OFFHIRE>') == false)? dummy :source.split('<REPORT_OFFHIRE>',3));
string[] REPORT_DATE=((source.contains('<REPORT_DATE>') == false)? dummy :source.split('<REPORT_DATE>',3));

String RptName = (Truck[0].Name+' '+REPORT_DATE[1].substring(0,16));

//Input db

Daily__c r = new Daily__c(Name = RptName, Truck_Name__c = Truck[0].ID, Email_from__c = email.fromAddress,
Object_ID__c=(integer.valueof(OBJECT_ID[1].trim().length()) == 0)? null :decimal.valueof(OBJECT_ID[1].trim()),
Operation_code__c=(integer.valueof(OPERATION_CODE[1].trim().length()) == 0)? null :decimal.valueof(OPERATION_CODE[1].trim()),
Report_Version__c=(integer.valueof(REPORT_VERSION[1].trim().length()) == 0)? Null :REPORT_VERSION[1],
Report_Noon__c=(integer.valueof(REPORT_NOON[1].trim().length()) == 0)? null :decimal.valueof(REPORT_NOON[1].trim()),
Report_Offhire__c=(integer.valueof(REPORT_OFFHIRE[1].trim().length()) == 0)? null :decimal.valueof(REPORT_OFFHIRE[1].trim()),
Report_Date__c=(REPORT_DATE[1] == '0' || integer.valueof(REPORT_DATE[1].trim().length()) == 0)? Null : datetime.valueof(REPORT_DATE[1])

);

upsert r Name; 
return result;
}
}

 

Test method:

@isTest
private class DailyRecieve_Test 
{
static testMethod void test234567() {

  // create a new email and envelope object
  Messaging.InboundEmail email = new Messaging.InboundEmail() ;
  Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
 
  // setup the data for the email
  email.subject = 'dailyreptest';
  email.fromname = 'FirstName LastName';
  env.fromAddress = 'someaddress123@someverifieddomain.com';
  email.plainTextBody= '<OBJECT_ID>334<OBJECT_ID>'
+'<License>123456<License>'
+'<OPERATION_CODE>4<OPERATION_CODE>'
+'<REPORT_VERSION>v.2.9<REPORT_VERSION>'
+'<REPORT_NOON>1<REPORT_NOON>'
+'<REPORT_OFFHIRE>0<REPORT_OFFHIRE>'
+'<REPORT_DATE>2012-01-04 18:00:00<REPORT_DATE>';
  
  // call the email service class and test it with the data in the testMethod
  DailyRecieve dailytest = new DailyRecieve();
  dailytest.handleInboundEmail(email, env);
  
  // query for the daily_report the email service created
  Daily__c daily = [select id, OBJECT_ID__c,  REPORT_NOON__c, REPORT_OFFHIRE__c, from Daily__c where OBJECT_ID__c = 334];
 
  System.assertEquals(daily.REPORT_NOON ,1);
  System.assertEquals(daily.REPORT_OFFHIRE,0);
  System.assertEquals(daily.OBJECT_ID__c,334);
 }
}

 

The thing is gives me 50% coverage. When looking at test coverage "line-for-line", all lines related to allocation of data to custom fields are colored red, meaning they are not properly tested. 

 

Any ideas?

I have a visualforce page i am using in my dashboard, where i have a SOQL query with a 

 

 where owner.id='{!$User.Id}'

argument. Is there a way of changing $User.Id to $Dashboardviewer.id or similar?

 

Now i have to log in as the relevant user to see what he sees. It would be easier to simply change to him as the viewer.

 

 

Say i have a custom object with following records:

 

Id, Employee Name, Report text, report date

=

1, Sarah, sfakjl, 2011/3/3

2, John, blablabla, 2011/1/1

3, Sarah, blablablabal, 2011/2/2

4, Erik, some text here, 2010/12/4

5, John, example text, 2011/2/3

6, John, blakjfd, 2011/1/2

 

And i want to have a SOQL query that lists the Latest (ie order by report date) record for each employee - so i only want ONE record returned per employee (limited to ONE per employee name), like this:

 

Query result= 

Sarah, sfakjl, 2011/3/3

John, example text, 2011/2/3

Erik, some text here, 2010/12/4

 

 

How do i do this? 

I want to have an array like this : 

 

var locations =[

['blabla', 12, -13.1],

['blabla again', -3.4, 150],

['asdf', 3.2, 0]

];

 

How do i use the below ajax toolkit connection to make such an array? Because what i am trying is  not working.

 

 

var records = sforce.connection.query("SELECT LatDecimal__c, LonDecimal__c FROM Report__c ORDER BY Report_Date__c LIMIT 2");

var locations = records.getArray("locations");

//???

 

Edit: typo.

I am trying to plot multiple markers in google maps, getting the data in an array through ajax toolkit. I am preeeetty sure i am making a mistake in handling the results from my soql query. 

 

Can one of you experts tell me what i am doing wrong?

 

<apex:page >
<head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="/soap/ajax/23.0/connection.js" type="text/javascript" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
        
$(document).ready(function() {


        sforce.connection.sessionId = '{!$Api.Session_ID}';

        // Query data using SOQL.
var records = sforce.connection.query("Select latdecimal__c, londecimal__c from daily__c where vehicle_name__c='a0DM0000000YgEK' order by report_date__c limit 2");
locations = records.getArray("locations");

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 10,
      center: new google.maps.LatLng(-33.92, 151.25),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infowindow = new google.maps.InfoWindow();

    var marker;
    var i;
       
for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][0], locations[i][1]),
        map: map
      });
  
    //add listeners
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
          return function() {
            infowindow.setContent(locations[i][0]);
            infowindow.open(map, marker);
            }
          })(marker,i));
     };
        

  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }
  
});
</script>

<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:250px;
  background:transparent;
}
</style>

</head>
 
<body>
<div id="map"></div> 
</body> 
</apex:page>

 

Hello people,

 

I am making a Google annotated timeline to put into my visualforce page. It is working fine in every way except for the fact that the format of the date field it extracts from salesforce is incompatible:

 

Type mismatch. Value 2011-06-23 does not match type date in column index 0

 

I believe the date has to be in the format of YYYY, MM, DD. Any ideas as to how i can change it over to this in my code?

 

 

 

Full VF page below:

<apex:page standardController="Vehicle__c">

<head>

<script type='text/javascript' src='https://www.google.com/jsapi' />
<script src="/soap/ajax/23.0/connection.js" type="text/javascript" />
<script type="text/javascript">

    google.load('visualization', '1', {'packages':['annotatedtimeline']});
    google.setOnLoadCallback(drawChart);
        sforce.connection.sessionId = '{!$Api.Session_ID}';

    function drawChart() {
        //table to act as the datasource for the timeline
        var data = new google.visualization.DataTable();
        data.addColumn('date', 'Date');
        data.addColumn('number', 'Fuel');

// Query data using SOQL.

var result = sforce.connection.query("Select day_only(report_date__c) Date, avg(Cons__c) Fuel From Report__c where Vehicle_name__c='{!vehicle__c.id}' group by day_only(report_date__c) order by day_only(report_date__c)");

// Iterate over the result
var it = new sforce.QueryResultIterator(result);
while(it.hasNext()) {
var record = it.next();
// Add the data to the table
data.addRow([record.Date, {v:parseFloat(record.Fuel)}]);
}

        var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
        chart.draw(data, {displayAnnotations: true});
      }
    </script>
  </head>
  <body>
    // Note how you must specify the size of the container element explicitly!
    <div id='chart_div' style='width: 700px; height: 240px;'></div>
  </body>
</apex:page>

 

Hi,

 

I am handling a inbound email which contains ~320 field values, contained in tags <field1>123<field1> etc.

 

This is handled in the following way:

//Retrieve data
string[] OBJECT_ID=email.plaintextbody.split('<OBJECT_ID>',3);
string[] FORM_OBJECT_ID=email.plaintextbody.split('<FORM_OBJECT_ID>',3);

//etc.. for 320 strings


Daily__c r = new Daily__c(Name = RptName, 
Object_ID__c=(OBJECT_ID[1] == null || integer.valueof(OBJECT_ID[1].trim().length()) == 0)? null :integer.valueof(OBJECT_ID[1].trim()),
Form_Object_ID__c=(FORM_OBJECT_ID[1] == null || integer.valueof(FORM_OBJECT_ID[1].trim().length()) == 0)? null :integer.valueof(FORM_OBJECT_ID[1].trim()),

//etc again with 320 lines

);

upsert r Name; 

 

Problem is when doing the testing of the code, before deploying to production, i get the error message:

554 Method exceeds maximum number of allowed op codes.  Please break this method into multiple, smaller methods.

 

So i understand my code might be abit inefficient. The question is, how can I fix this? I dont really understand exactly what limit i'm hitting either.

 

thanks for any help!

Hi,

 

I am using a custom object with data entered via email from an external form. Now, one field is the amount of cargo onboard a vehicle.

 

The problem is that this amount is only reported when the vehicle departs a given location, but is reported as zero in the intermediate reports until it departs a new location, upon which the amount of course changes.

 

For reporting purposes I need to be able to group all entries with the same amount of cargo, but I am not able to do this now. My idea is to make a new custom field (cargo_onboard) and (if cargo_departing=0) have the field search previous entries until it hits cargo_departing=greater than zero and then set cargo_onboard equal to this. But i cannot find the functionality in the custom formula field. Any ideas??

 

 

 

EDIT

This is further complicated because it must be able to seperate between different vehicles, using a spesific vehicle ID. This is one reason I have not been able to fix it using workflow rules.. 

I need to know how to handle nulls when creating a new record from an incoming e-mail. The email is in plain text, values seperated by newline, like this example:

 

--emailbody below--

3

v2.3

2011-01-01

1500

0

 

 

56

--

 

now i capture each line in one string list, so that mylist[0]='3', mylist[2]='2011-01-01' and so on.

I then make a new record and upsert, like this:

 

MyObject__c r = new MyObject__c(Name = RptName, V_Name__c = Car[0].ID, Email_from__c = email.fromAddress,

//input from string list

Object_ID__c = integer.valueof(mylist[0],
version__c = mylist[1],
Report_Date__c = date.valueof(mylist[2]),
field4__c = integer.valueof(mylist[3]),
field5__c = decimal.valueof(mylist[4]),
field6__c = decimal.valueof(mylist[5]),
field7__c = date.valueof(mylist[6]),

//etc

);

upsert r Name;

return result;

 

my problem is that, in this example, i will get an exception for field6__c and field7__c (554 System.TypeException: Invalid decimal (or invalid date): ) because it cannot take the decimal value of null, which is exactly what lines 5 and 6 in the mail contains.

 

how can i do this in a better way? I want to create the record even if some lines are empty. Almost none of the custom fields in my object are required. So I do not simply want an exception stopping the entire process just because some lines are null.

Hi,

 

I am recieving a email with data values for each field in my custom object on seperate lines. Some data are just numbers, others are text (up to 100 characters). The problem is that only the first 60 characters are captured from the text data.

 

Extract of code i am using in apex:

 

//Retrieve data
string r1 = emailBody[2];
string r2 = emailBody[3];
string r3 = emailBody[4];
string r4 = emailBody[5];
string r5 = emailBody[6];
string r6 = emailBody[7];

//input into object
Daily__c r = new Daily__c(Name = RptName, Name__c = Ship[0].ID, Email_from__c = email.fromAddress,
Field1__c = integer.valueof(r1),
Field2__c = integer.valueof(r2),
Field3__c = r3,
Field4__c = decimal.valueof(r4),
Report_date__c = date.valueof(r5),
Comments__c = r6

 

 

 

 

I.E. if there is 100 characters on line 7 in the email, only 60 are captured into Comments__c. How can I fix this?

 



Hi!

 

I am new to salesforce, and have been trying for a while now to figure out if its possible to create a custom object based on an existing table in my sql server database. I want to do this automatically because the table has 200+ fields, and it would be inefficient to create 200+ custom fields i guess. So: can i replicate the existing fields as custom fields in a custom object in salesforce?

I have a inbound email service handling .txt attachments coming from many different users around my organisation. All emails are sent using MS outlook.

 

Sometimes the text attachment will be recognized as binary attachment, and consequently discarded. In one case I am looking at now, if i forward the troublesome email with the attachment, it will always detect the attachment as binary. However if I store the attachment on my HDD, and create a new email with this file and send it, it will work. 

 

Any thoughts are highly appreciated!

Good day esteemed experts,

 

I am unable to increase the test coverage of my email-recieving class above ~50%.

 

Email Class:

 

global class DailyRecieve implements Messaging.InboundEmailHandler
{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,Messaging.InboundEnvelope envelope){
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

source=email.plaintextbody;

//prepare dummy list for use if data source does not contain certain fields
string[] dummy=new List<String> ();
dummy.add('');
dummy.add('');

//Retrieve Truck name from License number
string[] Licenseno = source.split('<License>',3);
string License= Licenseno[1].trim().substring(0);
Truck__c[] Truck = [select Name from Truck__c where License_no__c = :License Limit 1];


//Retrieve data
string[] OBJECT_ID=((source.contains('<OBJECT_ID>') == false)? dummy :source.split('<OBJECT_ID>',3));
string[] OPERATION_CODE=((source.contains('<OPERATION_CODE>') == false)? dummy :source.split('<OPERATION_CODE>',3));
string[] REPORT_VERSION=((source.contains('<REPORT_VERSION>') == false)? dummy :source.split('<REPORT_VERSION>',3));
string[] REPORT_NOON=((source.contains('<REPORT_NOON>') == false)? dummy :source.split('<REPORT_NOON>',3));
string[] REPORT_OFFHIRE=((source.contains('<REPORT_OFFHIRE>') == false)? dummy :source.split('<REPORT_OFFHIRE>',3));
string[] REPORT_DATE=((source.contains('<REPORT_DATE>') == false)? dummy :source.split('<REPORT_DATE>',3));

String RptName = (Truck[0].Name+' '+REPORT_DATE[1].substring(0,16));

//Input db

Daily__c r = new Daily__c(Name = RptName, Truck_Name__c = Truck[0].ID, Email_from__c = email.fromAddress,
Object_ID__c=(integer.valueof(OBJECT_ID[1].trim().length()) == 0)? null :decimal.valueof(OBJECT_ID[1].trim()),
Operation_code__c=(integer.valueof(OPERATION_CODE[1].trim().length()) == 0)? null :decimal.valueof(OPERATION_CODE[1].trim()),
Report_Version__c=(integer.valueof(REPORT_VERSION[1].trim().length()) == 0)? Null :REPORT_VERSION[1],
Report_Noon__c=(integer.valueof(REPORT_NOON[1].trim().length()) == 0)? null :decimal.valueof(REPORT_NOON[1].trim()),
Report_Offhire__c=(integer.valueof(REPORT_OFFHIRE[1].trim().length()) == 0)? null :decimal.valueof(REPORT_OFFHIRE[1].trim()),
Report_Date__c=(REPORT_DATE[1] == '0' || integer.valueof(REPORT_DATE[1].trim().length()) == 0)? Null : datetime.valueof(REPORT_DATE[1])

);

upsert r Name; 
return result;
}
}

 

Test method:

@isTest
private class DailyRecieve_Test 
{
static testMethod void test234567() {

  // create a new email and envelope object
  Messaging.InboundEmail email = new Messaging.InboundEmail() ;
  Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
 
  // setup the data for the email
  email.subject = 'dailyreptest';
  email.fromname = 'FirstName LastName';
  env.fromAddress = 'someaddress123@someverifieddomain.com';
  email.plainTextBody= '<OBJECT_ID>334<OBJECT_ID>'
+'<License>123456<License>'
+'<OPERATION_CODE>4<OPERATION_CODE>'
+'<REPORT_VERSION>v.2.9<REPORT_VERSION>'
+'<REPORT_NOON>1<REPORT_NOON>'
+'<REPORT_OFFHIRE>0<REPORT_OFFHIRE>'
+'<REPORT_DATE>2012-01-04 18:00:00<REPORT_DATE>';
  
  // call the email service class and test it with the data in the testMethod
  DailyRecieve dailytest = new DailyRecieve();
  dailytest.handleInboundEmail(email, env);
  
  // query for the daily_report the email service created
  Daily__c daily = [select id, OBJECT_ID__c,  REPORT_NOON__c, REPORT_OFFHIRE__c, from Daily__c where OBJECT_ID__c = 334];
 
  System.assertEquals(daily.REPORT_NOON ,1);
  System.assertEquals(daily.REPORT_OFFHIRE,0);
  System.assertEquals(daily.OBJECT_ID__c,334);
 }
}

 

The thing is gives me 50% coverage. When looking at test coverage "line-for-line", all lines related to allocation of data to custom fields are colored red, meaning they are not properly tested. 

 

Any ideas?

I have a visualforce page i am using in my dashboard, where i have a SOQL query with a 

 

 where owner.id='{!$User.Id}'

argument. Is there a way of changing $User.Id to $Dashboardviewer.id or similar?

 

Now i have to log in as the relevant user to see what he sees. It would be easier to simply change to him as the viewer.

 

 

I want to have an array like this : 

 

var locations =[

['blabla', 12, -13.1],

['blabla again', -3.4, 150],

['asdf', 3.2, 0]

];

 

How do i use the below ajax toolkit connection to make such an array? Because what i am trying is  not working.

 

 

var records = sforce.connection.query("SELECT LatDecimal__c, LonDecimal__c FROM Report__c ORDER BY Report_Date__c LIMIT 2");

var locations = records.getArray("locations");

//???

 

Edit: typo.

I am trying to plot multiple markers in google maps, getting the data in an array through ajax toolkit. I am preeeetty sure i am making a mistake in handling the results from my soql query. 

 

Can one of you experts tell me what i am doing wrong?

 

<apex:page >
<head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="/soap/ajax/23.0/connection.js" type="text/javascript" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
        
$(document).ready(function() {


        sforce.connection.sessionId = '{!$Api.Session_ID}';

        // Query data using SOQL.
var records = sforce.connection.query("Select latdecimal__c, londecimal__c from daily__c where vehicle_name__c='a0DM0000000YgEK' order by report_date__c limit 2");
locations = records.getArray("locations");

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 10,
      center: new google.maps.LatLng(-33.92, 151.25),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infowindow = new google.maps.InfoWindow();

    var marker;
    var i;
       
for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][0], locations[i][1]),
        map: map
      });
  
    //add listeners
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
          return function() {
            infowindow.setContent(locations[i][0]);
            infowindow.open(map, marker);
            }
          })(marker,i));
     };
        

  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }
  
});
</script>

<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:250px;
  background:transparent;
}
</style>

</head>
 
<body>
<div id="map"></div> 
</body> 
</apex:page>

 

Hello people,

 

I am making a Google annotated timeline to put into my visualforce page. It is working fine in every way except for the fact that the format of the date field it extracts from salesforce is incompatible:

 

Type mismatch. Value 2011-06-23 does not match type date in column index 0

 

I believe the date has to be in the format of YYYY, MM, DD. Any ideas as to how i can change it over to this in my code?

 

 

 

Full VF page below:

<apex:page standardController="Vehicle__c">

<head>

<script type='text/javascript' src='https://www.google.com/jsapi' />
<script src="/soap/ajax/23.0/connection.js" type="text/javascript" />
<script type="text/javascript">

    google.load('visualization', '1', {'packages':['annotatedtimeline']});
    google.setOnLoadCallback(drawChart);
        sforce.connection.sessionId = '{!$Api.Session_ID}';

    function drawChart() {
        //table to act as the datasource for the timeline
        var data = new google.visualization.DataTable();
        data.addColumn('date', 'Date');
        data.addColumn('number', 'Fuel');

// Query data using SOQL.

var result = sforce.connection.query("Select day_only(report_date__c) Date, avg(Cons__c) Fuel From Report__c where Vehicle_name__c='{!vehicle__c.id}' group by day_only(report_date__c) order by day_only(report_date__c)");

// Iterate over the result
var it = new sforce.QueryResultIterator(result);
while(it.hasNext()) {
var record = it.next();
// Add the data to the table
data.addRow([record.Date, {v:parseFloat(record.Fuel)}]);
}

        var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
        chart.draw(data, {displayAnnotations: true});
      }
    </script>
  </head>
  <body>
    // Note how you must specify the size of the container element explicitly!
    <div id='chart_div' style='width: 700px; height: 240px;'></div>
  </body>
</apex:page>

 

hi,

 I have a requirement to display a locations on the map based on the field called locations in a custom object.

some one please help me how can i dsplay a map on vfpage with pointing locations.when i click on each location the description about that location has to be displayed.when i click on a location it has to navigate me to other site like wikipedia o somethind..

 

plz help me

thank you

  • September 28, 2011
  • Like
  • 0

Hi,

 

I am using a custom object with data entered via email from an external form. Now, one field is the amount of cargo onboard a vehicle.

 

The problem is that this amount is only reported when the vehicle departs a given location, but is reported as zero in the intermediate reports until it departs a new location, upon which the amount of course changes.

 

For reporting purposes I need to be able to group all entries with the same amount of cargo, but I am not able to do this now. My idea is to make a new custom field (cargo_onboard) and (if cargo_departing=0) have the field search previous entries until it hits cargo_departing=greater than zero and then set cargo_onboard equal to this. But i cannot find the functionality in the custom formula field. Any ideas??

 

 

 

EDIT

This is further complicated because it must be able to seperate between different vehicles, using a spesific vehicle ID. This is one reason I have not been able to fix it using workflow rules.. 

I need to know how to handle nulls when creating a new record from an incoming e-mail. The email is in plain text, values seperated by newline, like this example:

 

--emailbody below--

3

v2.3

2011-01-01

1500

0

 

 

56

--

 

now i capture each line in one string list, so that mylist[0]='3', mylist[2]='2011-01-01' and so on.

I then make a new record and upsert, like this:

 

MyObject__c r = new MyObject__c(Name = RptName, V_Name__c = Car[0].ID, Email_from__c = email.fromAddress,

//input from string list

Object_ID__c = integer.valueof(mylist[0],
version__c = mylist[1],
Report_Date__c = date.valueof(mylist[2]),
field4__c = integer.valueof(mylist[3]),
field5__c = decimal.valueof(mylist[4]),
field6__c = decimal.valueof(mylist[5]),
field7__c = date.valueof(mylist[6]),

//etc

);

upsert r Name;

return result;

 

my problem is that, in this example, i will get an exception for field6__c and field7__c (554 System.TypeException: Invalid decimal (or invalid date): ) because it cannot take the decimal value of null, which is exactly what lines 5 and 6 in the mail contains.

 

how can i do this in a better way? I want to create the record even if some lines are empty. Almost none of the custom fields in my object are required. So I do not simply want an exception stopping the entire process just because some lines are null.

Hi,

 

I am recieving a email with data values for each field in my custom object on seperate lines. Some data are just numbers, others are text (up to 100 characters). The problem is that only the first 60 characters are captured from the text data.

 

Extract of code i am using in apex:

 

//Retrieve data
string r1 = emailBody[2];
string r2 = emailBody[3];
string r3 = emailBody[4];
string r4 = emailBody[5];
string r5 = emailBody[6];
string r6 = emailBody[7];

//input into object
Daily__c r = new Daily__c(Name = RptName, Name__c = Ship[0].ID, Email_from__c = email.fromAddress,
Field1__c = integer.valueof(r1),
Field2__c = integer.valueof(r2),
Field3__c = r3,
Field4__c = decimal.valueof(r4),
Report_date__c = date.valueof(r5),
Comments__c = r6

 

 

 

 

I.E. if there is 100 characters on line 7 in the email, only 60 are captured into Comments__c. How can I fix this?

 



Hi!

 

I am new to salesforce, and have been trying for a while now to figure out if its possible to create a custom object based on an existing table in my sql server database. I want to do this automatically because the table has 200+ fields, and it would be inefficient to create 200+ custom fields i guess. So: can i replicate the existing fields as custom fields in a custom object in salesforce?