• Joaquin_tegui
  • NEWBIE
  • 25 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 8
    Replies

Hi All, 

I'm having an Issue when assigning a Task to a Queue. Right now if I crate a task in Annonymous apex with a queue ID everything works perfectly. But if I do it though a class of Inbound Email or a REST resource it fails. The error is that it does not recogni the queue ID.

Here is my code for the Email Service

global class inboundEmailTaskCreation implements Messaging.InboundEmailHandler {

    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,
            Messaging.InboundEnvelope env){

        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

        String EmailBody= '';

        EmailBody = email.plainTextBody;

        Task newTask = new Task();

        try {
//Getting the queue Id
            Group gradoQueue = [SELECT ID from Group WHERE Type = 'Queue' AND DeveloperNAME = 'Grado' ];

//Creating the task
            newTask = new Task(Description = myPlainText,
                    Priority = 'Normal',
                    Subject = 'Correo Electrónico: ' + email.subject,
                    Status = 'Open',
                    ActivityDate = Date.today()
                    );



            insert newTask;

            System.debug('New Task Object: ' + newTask );
        }
        catch (QueryException e) {
            System.debug('Query Issue: ' + e);
        }

        result.success = true;

        return result;
    }
}

Any help will be useuful!

Thanks
Hi All, I've been struggling with this issue and couldn't find the solution

I'm trying to use SOPAUI to try some Webservices I made but whenever i create a project from the enterprise WSDL I get this error
 
Error: type 'AdditionalInformationMap@urn:enterprise.soap.sforce.com' not found.

I looked everywhere and the only thing I can think of doing is adding the type myself but not sure how.

Appreciate the help

 

Hi all, 
We are currently migrating our service desk (mailing only) from a bunch of games accounts to the Service Console. Now everything is going great and users love sending mails directly from the case view.

My problem is that they need to have the gmail history available to know if a person was already contacted, etc. The thing is that this history is about 400k mails that we cannot upload to Salesforce for storage reasons. 

I've been trying different approaches like uploading the mails on a server and accessing them through a VFP or an External link but dealing with emails is a painspecially with the gmail mailbox format, I've been looking into the gmail API but I have little experience in this field.

Did anyone had this issue before? how did you approach it?

Hi All,

I have a Visualforce page with several charts done with Google Visualization API and some SOQL Queries. We want to have this page in a monitor in the office to have Live Data from Salesforce.

My question is, Can I use a Meta tag to refresh the page once every hour for example? Or would I hit any governor Limit?

Thanks in advance
Hi, 

I'm trying to make a public form that prefills fields with a contact through a parameter. I'm able to do this in FormAssembly but I'm having troubles understanding the Secure Parameters way in this link https://help.formassembly.com/help/508885-prefill-lookups-using-secure-parameters.

I don't understand how can i use that to export the data and send a mass email. Could someone explain me where should i use that visualforce code in the example?

Also i would like to know how hard is it to do this with Visualforce and a Site.

Sorry for the noob question and my english
Hi, this is the first time I do an important trigger and test class, and the first time asking for help!

I'm writing a trigger to convert leads automatically for an organization that doesn't use leads and wants all leads converted.

These are the requirements:
If the email field of the lead exist as a contact it merge the converted lead with that Contact and Creates an opportunity.
If the email field of the lead is blank it only converts it as a Account and Contact with no opportunity
If the email field of the lead is new (is not in a contact) it converts the lead into Account, Contact and Opportunity

The trigger is working fine (although comments are much appreciated) but I'm stuck in the Test class and needing some guidance.

This is my trigger:
trigger AutoConvert on Lead (after insert) {
    
    list<Lead> LeadsSinDup   = new list<Lead>();
    list<Lead> LeadsDup      = new List<Lead>();
    list<Lead> LeadsSinEmail = new List<Lead>();
   
    for(Lead myLead: Trigger.new){
        list<Contact> contactDupEmail = [SELECT Id FROM Contact WHERE Email = :myLead.Email LIMIT 1];
        if(contactDupEmail.size() == 0) {
            LeadsSinDup.add(myLead);
        }else if(myLead.Email == NULL ){
            LeadsSinEmail.add(myLead);
        }else{
            LeadsDup.add(myLead);
        }
    }

    list<Database.LeadConvert> leadConvertsSinDup = new list<Database.LeadConvert>();
    list<Database.LeadConvert> leadConvertsDup    = new list<Database.LeadConvert>();
    list<Database.LeadConvert> leadConvertSinMail = new list<Database.LeadConvert>();
    
    for(Lead myLead : LeadsSinDup){
        Database.LeadConvert leadSinDup = new database.LeadConvert();
        leadSinDup.setLeadId(myLead.Id);
        leadSinDup.convertedStatus = 'Closed - Converted';
        Database.ConvertLead(leadSinDup,true);
        leadConvertsSinDup.add(leadSinDup);
    }
    
    for(Lead myLead : LeadsDup){
        List<Contact> contactDup = [SELECT Id, AccountId, Title  FROM Contact WHERE Email = :myLead.Email LIMIT 1];
        Database.LeadConvert leadDup = new database.LeadConvert();
        leadDup.setLeadId(myLead.Id);
        leadDup.setAccountId(contactDup[0].AccountId);
        leadDup.setContactId(contactDup[0].id);
        leadDup.convertedStatus = 'Closed - Converted';
        leadConvertsDup.add(leadDup);
    } 
    
    for(Lead myLead : LeadsSinEmail){
        Database.LeadConvert LeadSinEmail = new database.LeadConvert();
        LeadSinEmail.setLeadId(myLead.Id);
        LeadSinEmail.convertedStatus = 'Closed - Converted';
        LeadSinEmail.setDoNotCreateOpportunity(true);
        leadConvertSinMail.add(LeadSinEmail);
    }
    
    Database.convertLead(leadConvertsDup,true);
    Database.convertLead(leadConvertSinMail,true);
    Database.convertLead(leadConvertsSinDup,true);
}

This is the test i got so far:
 
@isTest

private class TestAutoConvert {
	
    static testMethod void leadTest(){
        List<Lead> leadsConv     = new List<Lead>();
                
        Contact testContacto     = new Contact();
        testContacto.LastName    = 'salesforce';
        testContacto.Email       = 'duplicado@dup.com';
        
        Lead testLeadNoDup       = new Lead();
        testLeadNoDup.LastName   = 'joaquin';
        testLeadNoDup.Company    = 'La Cle';
        testLeadNoDup.Email      = 'joaquin@lacle.com';
        leadsConv.add(testLeadNoDup);
        
        Lead testLeadDup         = new Lead();
        testLeadDup.LastName     = 'Elena';
        testLeadDup.Company      = 'MVP';
        testLeadDup.Email        = 'duplicado@dup.com';
        leadsConv.add(testLeadDup);

        
        Lead testLeadNoMail      = new Lead();
        testLeadNoMail.LastName  = 'John';
        testLeadNoMail.Company   = 'No email';
        leadsConv.add(testLeadNoMail);
        
        
        insert testContacto;
		insert leadsConv;
     
        System.assert(testLeadDup.IsConverted);
        System.assertEquals(testContacto.AccountId,testLeadDup.ConvertedAccountId);
        System.assertEquals(testContacto.Id, testLeadDup.ConvertedContactId);
        
        System.assertEquals(true, testLeadNoDup.IsConverted);
        System.assertNotEquals(null, testLeadNoDup.ConvertedOpportunityId);
        
        System.assertEquals(true, testLeadNoMail.IsConverted);
        System.assertEquals(null, testLeadNoMail.ConvertedOpportunityId);
               
        
        
    }
}

This is the error I'm getting:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutoConvert: execution of AfterInsert

caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, accountId must be specified if contactId is not null: [Id]

Trigger.AutoConvert: line 48, column 1: []
And the Stack trace says 'Class.TestAutoConvert.leadTest: line 32, column 1'

When i do it manually it works, I don't understand why it's failing.

Thanks in advance, hope I'm in the right direction, please excuse me for the spanish variable names.

 

Hi all, 
We are currently migrating our service desk (mailing only) from a bunch of games accounts to the Service Console. Now everything is going great and users love sending mails directly from the case view.

My problem is that they need to have the gmail history available to know if a person was already contacted, etc. The thing is that this history is about 400k mails that we cannot upload to Salesforce for storage reasons. 

I've been trying different approaches like uploading the mails on a server and accessing them through a VFP or an External link but dealing with emails is a painspecially with the gmail mailbox format, I've been looking into the gmail API but I have little experience in this field.

Did anyone had this issue before? how did you approach it?

Hi All,

I have a Visualforce page with several charts done with Google Visualization API and some SOQL Queries. We want to have this page in a monitor in the office to have Live Data from Salesforce.

My question is, Can I use a Meta tag to refresh the page once every hour for example? Or would I hit any governor Limit?

Thanks in advance
Hi Friends,
I'm finishing up the Apex Basics Badge (yay!) and want to follow the recommended syntax. There's another answer posted on here that passes the challenge but uses syntax that is different than what is taught in the documentation. I really want to understand where I'm going wrong as I think I'm pretty close. Thanks for your feedback!
Here's my code:

public class ContactAndLeadSearch {

    public static void List<List<sObject>> searchContactsAndLeads = [FIND 'Smith' IN NAME FIELDS RETURNING
                                                 Lead (FirstName,LastName),Contact(FirstName,LastName)];
    
    Lead[] searchLeads = (Lead[])searchList[0];
    Contact[] searchContacts = (Contact[])searchList[1];
 
    System.debug('Found the following Lead.');
    for (Lead l : searchLeads) {
        System.debug(l.FirstName);
    }
    System.debug('Found the following contacts.');
    for (Contact c : searchContacts) {
        System.debug(c.LastName + ', ' + c.FirstName);
    }
    
}

Here's the challenge:
Create an Apex class that returns both contacts and leads based on a parameter.
With SOSL you can search against different object types that may have similar data, such as contacts and leads. To pass this challenge, create an Apex class that returns both contacts and leads that have first or last name matching the incoming parameter.
  • The Apex class must be called 'ContactAndLeadSearch' and be in the public scope.
  • The Apex class must have a public static method called 'searchContactsAndLeads'.
  • Because SOSL indexes data for searching, you must create a Contact record and Lead record before checking this challenge. Both records must have the last name 'Smith'. The challenge uses these records for the SOSL search.
  • The return type for 'searchContactsAndLeads' must be 'List<List< SObject>>'
  • The 'searchContactsAndLeads' method must accept an incoming string as a parameter, find any contact or lead that matches the string as part of either the first or last name and then return those records.
My current error message is: unexpected token: 'List' in line 3.
My questions: I'm not sure how to best invoke the public static method and still have the return type 'List..' Thanks for your help!
 
Hi, 

I'm trying to make a public form that prefills fields with a contact through a parameter. I'm able to do this in FormAssembly but I'm having troubles understanding the Secure Parameters way in this link https://help.formassembly.com/help/508885-prefill-lookups-using-secure-parameters.

I don't understand how can i use that to export the data and send a mass email. Could someone explain me where should i use that visualforce code in the example?

Also i would like to know how hard is it to do this with Visualforce and a Site.

Sorry for the noob question and my english
Hi, this is the first time I do an important trigger and test class, and the first time asking for help!

I'm writing a trigger to convert leads automatically for an organization that doesn't use leads and wants all leads converted.

These are the requirements:
If the email field of the lead exist as a contact it merge the converted lead with that Contact and Creates an opportunity.
If the email field of the lead is blank it only converts it as a Account and Contact with no opportunity
If the email field of the lead is new (is not in a contact) it converts the lead into Account, Contact and Opportunity

The trigger is working fine (although comments are much appreciated) but I'm stuck in the Test class and needing some guidance.

This is my trigger:
trigger AutoConvert on Lead (after insert) {
    
    list<Lead> LeadsSinDup   = new list<Lead>();
    list<Lead> LeadsDup      = new List<Lead>();
    list<Lead> LeadsSinEmail = new List<Lead>();
   
    for(Lead myLead: Trigger.new){
        list<Contact> contactDupEmail = [SELECT Id FROM Contact WHERE Email = :myLead.Email LIMIT 1];
        if(contactDupEmail.size() == 0) {
            LeadsSinDup.add(myLead);
        }else if(myLead.Email == NULL ){
            LeadsSinEmail.add(myLead);
        }else{
            LeadsDup.add(myLead);
        }
    }

    list<Database.LeadConvert> leadConvertsSinDup = new list<Database.LeadConvert>();
    list<Database.LeadConvert> leadConvertsDup    = new list<Database.LeadConvert>();
    list<Database.LeadConvert> leadConvertSinMail = new list<Database.LeadConvert>();
    
    for(Lead myLead : LeadsSinDup){
        Database.LeadConvert leadSinDup = new database.LeadConvert();
        leadSinDup.setLeadId(myLead.Id);
        leadSinDup.convertedStatus = 'Closed - Converted';
        Database.ConvertLead(leadSinDup,true);
        leadConvertsSinDup.add(leadSinDup);
    }
    
    for(Lead myLead : LeadsDup){
        List<Contact> contactDup = [SELECT Id, AccountId, Title  FROM Contact WHERE Email = :myLead.Email LIMIT 1];
        Database.LeadConvert leadDup = new database.LeadConvert();
        leadDup.setLeadId(myLead.Id);
        leadDup.setAccountId(contactDup[0].AccountId);
        leadDup.setContactId(contactDup[0].id);
        leadDup.convertedStatus = 'Closed - Converted';
        leadConvertsDup.add(leadDup);
    } 
    
    for(Lead myLead : LeadsSinEmail){
        Database.LeadConvert LeadSinEmail = new database.LeadConvert();
        LeadSinEmail.setLeadId(myLead.Id);
        LeadSinEmail.convertedStatus = 'Closed - Converted';
        LeadSinEmail.setDoNotCreateOpportunity(true);
        leadConvertSinMail.add(LeadSinEmail);
    }
    
    Database.convertLead(leadConvertsDup,true);
    Database.convertLead(leadConvertSinMail,true);
    Database.convertLead(leadConvertsSinDup,true);
}

This is the test i got so far:
 
@isTest

private class TestAutoConvert {
	
    static testMethod void leadTest(){
        List<Lead> leadsConv     = new List<Lead>();
                
        Contact testContacto     = new Contact();
        testContacto.LastName    = 'salesforce';
        testContacto.Email       = 'duplicado@dup.com';
        
        Lead testLeadNoDup       = new Lead();
        testLeadNoDup.LastName   = 'joaquin';
        testLeadNoDup.Company    = 'La Cle';
        testLeadNoDup.Email      = 'joaquin@lacle.com';
        leadsConv.add(testLeadNoDup);
        
        Lead testLeadDup         = new Lead();
        testLeadDup.LastName     = 'Elena';
        testLeadDup.Company      = 'MVP';
        testLeadDup.Email        = 'duplicado@dup.com';
        leadsConv.add(testLeadDup);

        
        Lead testLeadNoMail      = new Lead();
        testLeadNoMail.LastName  = 'John';
        testLeadNoMail.Company   = 'No email';
        leadsConv.add(testLeadNoMail);
        
        
        insert testContacto;
		insert leadsConv;
     
        System.assert(testLeadDup.IsConverted);
        System.assertEquals(testContacto.AccountId,testLeadDup.ConvertedAccountId);
        System.assertEquals(testContacto.Id, testLeadDup.ConvertedContactId);
        
        System.assertEquals(true, testLeadNoDup.IsConverted);
        System.assertNotEquals(null, testLeadNoDup.ConvertedOpportunityId);
        
        System.assertEquals(true, testLeadNoMail.IsConverted);
        System.assertEquals(null, testLeadNoMail.ConvertedOpportunityId);
               
        
        
    }
}

This is the error I'm getting:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AutoConvert: execution of AfterInsert

caused by: System.DmlException: ConvertLead failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, accountId must be specified if contactId is not null: [Id]

Trigger.AutoConvert: line 48, column 1: []
And the Stack trace says 'Class.TestAutoConvert.leadTest: line 32, column 1'

When i do it manually it works, I don't understand why it's failing.

Thanks in advance, hope I'm in the right direction, please excuse me for the spanish variable names.

 
I am lost trying to create validation rules for the challenge in the one trailhead. The instructions mention the following:

add a validation rule which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).

I have tried the following formulas and keep getting syntax errors"

API NAME MailingPostalCode
NOT (ISBLANK(API NAME SHIPPINGPOSTALCODE)

MAILINGPOSTALCODE
NOT (ISBLANK(SHIPPINGPOSTALCODE))

None of these have worked.

Can someone please help?