• Jonas Myhre
  • NEWBIE
  • 30 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 16
    Replies
Hello! I've written an email service which i need to test the code coverage for, and increase it. Its currently at 62%, and needs to be minimun 75%.  Im stuck, can anyone help me, or point me in the right direction? Here is the code, i appreciate help extremely much! : 

global class EmailToLead implements Messaging.InboundEmailHandler {
 
        global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
            Messaging.InboundEnvelope envelope) {
 
            Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
 
             Lead lead = new Lead();
            lead.FirstName = email.fromname.substring(0,email.fromname.indexOf(' '));
            lead.LastName = email.fromname.substring(email.fromname.indexOf(' '));
            lead.Email = envelope.fromAddress;
            lead.Title = email.subject;
            lead.LeadSource = 'Market Intel';
            String textBody = email.plainTextBody;
            lead.Description = textBody;
            String companyName;
            if(textBody.indexOf('CompanyName:') > -1) {
                Integer startPos = textBody.indexOf('CompanyName:');
                Integer endPos = textBody.indexOf('.',textBody.indexOf('CompanyName:'));
                companyName = textBody.substring(startPos+'CompanyName:'.length(),endPos);
            }
            
            lead.Company = companyName != NULL ? companyName : '(not provided)';
            lead.Status = 'Web';
            insert lead;
     
            if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
            for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
            Attachment attachment = new Attachment();
            // attach to the newly created contact record
            attachment.ParentId = lead.Id;
            attachment.Name = email.binaryAttachments[i].filename;
            attachment.Body = email.binaryAttachments[i].body;
            insert attachment;
          }
    }
    return result;
}
}
Hello, im trying to set up an email service which creates a lead. I have tried the appexchange options, but they either cost money, or doesnt have the required functionality. 

The email service needs to accept attachments, and have a way to distinguish between emails sent in with the subject "Case" or "Intel", this can either be done after the email service, the important thing is the attachments part. 

Does anyone have some simple code / guidance for me here? I would appreciate it very much! 
Hey, im trying to create a Javascript button that creates a custom object from Opportunity. The code i have so far is probably not the best, i've pasted it below. I get "Unexpected Identifier" error message.

Thanks for help!

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var billing = new sforce.SObject('Billing__c');

{!Opportunity.Name} = "{!Billing__c.Name}";
{!Opportunity.Contact_Id__c}="{!Billing__c.Contact_Person__c}";
{!Opportunity.AccountId}="{!Billing__c.Account_nameId__c}";


result = sforce.connection.create([billing]);
Hi guys, need some help. Im creating a VF page, where i want to select a field and populate the text field right next to it with text. How would i go forth and do that?

I attached a photo below to illustrate. Red, white and blue should display different text in the text area right next to it.

Capture

Thanks alot!
Hi guys, this will be quite hard to explain, but i will try my best:

I have created a custom object called "Drift status" (currently a draft in the sandbox). This is created so we have an easy way to show our current issues to both our customers and internal users. I have then created an Apex class which gets this information and i use that as a visual force area home page component. It works fine if i have 1 active record (defined by a checkbox called "Visible"), if i have more or less it gives an error message. Im not fairly experienced in programming, so i need some help here. Ill post my code below:


Apex class:
global with sharing class driftsStatus{

     public Drift_Status__c status{get;set;}

     public driftsStatus() {

         status= [select Comment__c,ETA_Fix__c,Service__c from Drift_Status__c where Visible__c = true];
        

      }

}

So i need some guides on how to handle it if Visible__C count is less or more than 1. I would like to show all the records if there are more than 1, and a message if its 0 visible. Thanks alot
Hi

I am brand new to Apex and development, and i have a few questions i hope can be answered. I've created a custom object called "Drift Status". I want to create a VF area where i can show this if its set to "active". Can this be done? If so, how? And if not, what are similar approaches?

Thanks alot.
Hello! I've written an email service which i need to test the code coverage for, and increase it. Its currently at 62%, and needs to be minimun 75%.  Im stuck, can anyone help me, or point me in the right direction? Here is the code, i appreciate help extremely much! : 

global class EmailToLead implements Messaging.InboundEmailHandler {
 
        global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
            Messaging.InboundEnvelope envelope) {
 
            Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
 
             Lead lead = new Lead();
            lead.FirstName = email.fromname.substring(0,email.fromname.indexOf(' '));
            lead.LastName = email.fromname.substring(email.fromname.indexOf(' '));
            lead.Email = envelope.fromAddress;
            lead.Title = email.subject;
            lead.LeadSource = 'Market Intel';
            String textBody = email.plainTextBody;
            lead.Description = textBody;
            String companyName;
            if(textBody.indexOf('CompanyName:') > -1) {
                Integer startPos = textBody.indexOf('CompanyName:');
                Integer endPos = textBody.indexOf('.',textBody.indexOf('CompanyName:'));
                companyName = textBody.substring(startPos+'CompanyName:'.length(),endPos);
            }
            
            lead.Company = companyName != NULL ? companyName : '(not provided)';
            lead.Status = 'Web';
            insert lead;
     
            if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
            for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
            Attachment attachment = new Attachment();
            // attach to the newly created contact record
            attachment.ParentId = lead.Id;
            attachment.Name = email.binaryAttachments[i].filename;
            attachment.Body = email.binaryAttachments[i].body;
            insert attachment;
          }
    }
    return result;
}
}
Hello, im trying to set up an email service which creates a lead. I have tried the appexchange options, but they either cost money, or doesnt have the required functionality. 

The email service needs to accept attachments, and have a way to distinguish between emails sent in with the subject "Case" or "Intel", this can either be done after the email service, the important thing is the attachments part. 

Does anyone have some simple code / guidance for me here? I would appreciate it very much! 
I posted a picture below to show the issue. When I signed up for Site.com Studio for Community yesterday I had access to "data elements" and "data repeater", but now I do not.

Things that I have tried:
  • searched through help and training for 2 hours and did not find what I was looking for.
  • I read through the entire Community manual
  • I tried changing permissions
  • I tried changing "guest user settings"

No access to Data Elements
Hey, im trying to create a Javascript button that creates a custom object from Opportunity. The code i have so far is probably not the best, i've pasted it below. I get "Unexpected Identifier" error message.

Thanks for help!

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}

var billing = new sforce.SObject('Billing__c');

{!Opportunity.Name} = "{!Billing__c.Name}";
{!Opportunity.Contact_Id__c}="{!Billing__c.Contact_Person__c}";
{!Opportunity.AccountId}="{!Billing__c.Account_nameId__c}";


result = sforce.connection.create([billing]);
Hi guys, this will be quite hard to explain, but i will try my best:

I have created a custom object called "Drift status" (currently a draft in the sandbox). This is created so we have an easy way to show our current issues to both our customers and internal users. I have then created an Apex class which gets this information and i use that as a visual force area home page component. It works fine if i have 1 active record (defined by a checkbox called "Visible"), if i have more or less it gives an error message. Im not fairly experienced in programming, so i need some help here. Ill post my code below:


Apex class:
global with sharing class driftsStatus{

     public Drift_Status__c status{get;set;}

     public driftsStatus() {

         status= [select Comment__c,ETA_Fix__c,Service__c from Drift_Status__c where Visible__c = true];
        

      }

}

So i need some guides on how to handle it if Visible__C count is less or more than 1. I would like to show all the records if there are more than 1, and a message if its 0 visible. Thanks alot
Hi

I am brand new to Apex and development, and i have a few questions i hope can be answered. I've created a custom object called "Drift Status". I want to create a VF area where i can show this if its set to "active". Can this be done? If so, how? And if not, what are similar approaches?

Thanks alot.