• TintuBabu
  • NEWBIE
  • 200 Points
  • Member since 2016

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 33
    Replies
/* class */

Global class emailHelper {
public static void sendEmail(ID recipient, ID candidate) {
//New instance of a single email message
Messaging.SingleEmailMessage mail =

            new Messaging.SingleEmailMessage();

  

// Who you are sending the email to

   mail.setTargetObjectId(recipient);

 

   // The email template ID used for the email

   mail.setTemplateId('');

           

   mail.setWhatId(candidate);   

   mail.setBccSender(false);

   mail.setUseSignature(false);

   mail.setReplyTo('recruiting@acme.com');

   mail.setSenderDisplayName('HR Recruiting');

   mail.setSaveAsActivity(false); 

 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

    } 

}

/* testclass */


@istest

public class emailHelpertest{

public static testmethod void testvalidate(){

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
User u = new User(Alias = 'test1', Email='test@gamil.com',FirstName = 'Test', 
            EmailEncodingKey='UTF-8', LastName='Testlast', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='test111@gmail.com');
            insert u;
ID candidate;
ID recipient;

Contact con=new Contact();
con.lastname='Testing';
insert con;

test.starttest();
//mail.setTemplateId('');
mail.setTargetObjectId(recipient);
mail.setWhatId(candidate);   
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setReplyTo('recruiting@acme.com');
mail.setSenderDisplayName('HR Recruiting');
mail.setSaveAsActivity(false); 
emailHelper ehelp=new emailHelper();
emailHelper.sendEmail(recipient,candidate);
test.stoptest();
}
}

But this test class has an error saying invalid id.It is able to cover only 41%.Please help.
Hi everyone!

I have a visualforce page that contains a pageBlockButtons for Save/Cancel (1), and a pageBlockTable which one of the columns is a commandLink or commandButton (2) corresponding to an action to be done on that row's data.

Just to clarify what my buttons will do, the (1) buttons will already redirect the user to the previous page, but the (2) buttons/links will alter the data in the pageBlockTable and refresh the table.

But I want to avoid my users to be clicking endlessly with impatience and firing multiple events at once, so I would like to disable clicking any of those options (1 or 2) whenever one of them is pressed and while has not finishing processing. How can I do that?

Thanks in advance.
 Hi All,

I am getting an exception 

USER_DEBUG [6]|DEBUG|System.DmlException: Upsert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>: []

when I am trying to insert an EntitySubscription  record

EntitySubscription en=new EntitySubscription(NetworkId = commId, SubscriberId = sid, ParentId = pid);
try{upsert en;}catch(Exception e){System.debug(e);}

I checked for duplicate records but there are no duplicate i could find in workbench

Thanks
global class sendEmailtoVolntr implements schedulable,Database.Batchable<sObject>,Database.Stateful
{
    global String Query = null;

    global sendEmailtoVolntr (){
  
       Query='Select Id,Name,For_Centre__c,For_Date__c,Leap_Centre__c,Leap_Centre__r.Name,Send_Email__c,Short_Description__c,Uploaded_By__c from Leap_Weekly_Curriculum__c where Send_Email__c = FALSE and For_Date__c >= TODAY';
   
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(Query);
    }
    
    global void execute(SchedulableContext SC){
        sendEmailtoVolntr sendEmail= new sendEmailtoVolntr ();
        database.executebatch(sendEmail,1);
     }
    
    global void execute(Database.BatchableContext BC, List<sObject> scope){
    
        List<Attachment> attachments = new List<Attachment> ();
        Map<Id,Attachment> attachmentId = new Map<Id,Attachment> ();
        Set<Id> LeapIds = new Set<Id> ();
        List<Leap_Weekly_Curriculum__c> leapCurrilist = new List<Leap_Weekly_Curriculum__c> ();
        List<Leap_Weekly_Curriculum__c> updateLeapList = new List<Leap_Weekly_Curriculum__c> ();
    
        for(sObject so : scope){ 
    
            Leap_Weekly_Curriculum__c leapCurri= (Leap_Weekly_Curriculum__c)so;
            LeapIds.add(leapcurri.Id);
            leapCurrilist.add(leapCurri);
           } 
        attachments = [SELECT Id,ParentId, Name, Body, ContentType FROM Attachment WHERE Parentid IN :LeapIds];
          //Assuming that there will be only one attachment for each Leap Curriculum record           
        for(Attachment att : attachments)
        {
            attachmentId.put(att.ParentId,att);
        }
        attachments.clear();
        
        for(Leap_Weekly_Curriculum__c LWC: leapCurrilist)
        {
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            List<Messaging.SingleEmailMessage> theEmails = new List<Messaging.SingleEmailMessage> ();
            List<Messaging.EmailFileAttachment> emailAttachments = new List<Messaging.EmailFileAttachment>();
            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
            List<String> toAddresses = new List<String> ();
            String emailErrorReport = null;
            
            for(Volunteers__c vol: [Select Email__c from Volunteers__c WHERE Centre_Allocation__c includes(:LWC.Leap_Centre__r.Name)])
            toAddresses.add(vol.Email__c);
            //List<Volunteers__c> volListTeamp = [Select Email__c from Volunteers__c WHERE Centre_Allocation__c includes(:LWC.Leap_Centre__r.Name)];
            system.debug(toAddresses);
    
            efa.setFileName(attachmentId.get(LWC.Id).Name);
            efa.setBody(attachmentId.get(LWC.Id).Body);
            efa.setContentType(attachmentId.get(LWC.Id).ContentType);
            emailAttachments.add(efa);
            
            if(emailAttachments.size() > 0)
            {
                email.setToAddresses(toAddresses);
                email.setSubject('test');
                email.setPlainTextBody('For Leap Curriculum : ID -  ' + LWC.Id + ' Name - ' + LWC.Name + ' Short Description - ' + LWC.Short_Description__c + '.');
                email.setFileAttachments(emailAttachments);
                theEmails.add(email);
            }
            
            if(theEmails.size() > 0)
            {
                
                Messaging.SendEmailResult[] results = Messaging.sendEmail(theEmails,false);
                Messaging.SendEmailError[] errors = new List<Messaging.SendEmailError>();
                
                for( Messaging.SendEmailResult currentResult : results ) 
                {
                    errors = currentResult.getErrors();
                    if( null != errors ) 
                    {
                        for( Messaging.SendEmailError currentError : errors ) 
                        {
                            emailErrorReport = emailErrorReport + '(' +  currentError.getStatusCode() + ')' + currentError.getMessage() + '\r' ;
                        }
                    }
                }
    
                system.debug('error : ' + emailErrorReport);

             }

            System.debug('HEAP_SIZE Used:'+ Limits.getHeapSize()); 
            
            if(emailErrorReport != null){
                break;
            }
            else
            {
                LWC.send_EMail__c = TRUE;
                updateLeapList.add(LWC);  
            }
            
            if(updateLeapList.size()>0)
            update updateLeapList;
            
            if(emailErrorReport != null){
                System.abortJob(BC.getJobId()); 
                List<sObject> so = scope;
                Leap_Weekly_Curriculum__c lwcr= (Leap_Weekly_Curriculum__c )so[0];          
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresseser = new String[] {'rahmeshms@outlook.com'};
                mail.setToAddresses(toAddresseser);
                mail.setSubject('Email Job is aborted'); 
                mail.setPlainTextBody('The send email job is aborted due to Leap Curriculum : '+lwcr.Name+' '+lwcr.Short_Description__c+ ' '+lwcr.Id+ 'Please check the error report and take action accordingly.\n\n\t Error - '+emailErrorReport);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
            }
       } 
       
   }
global void finish(Database.BatchableContext BC){

    }


    
        }

I'm new to development and need help writing a test class for this batch class. I have no idea where to start or end. Please help out.

Thanks,
Avinash
Hi, 
I'm trying to include a Sankey Google Chart on a VisualForcePage. Everything works quite well, until I add a tabpanel on the page. In the JS console, I then have errors like "$A is not a function"
The main consequence is that the mouse-hovering is not working anymore.

Here is a simple example with a very simple tabpanel (without it, everything works well) :
<apex:page standardController="Account"  tabStyle="Account" >
<apex:detail relatedList="true" title="true" inlineEdit="true" showChatter="true"/>
   <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['sankey']});
      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'From');
        data.addColumn('string', 'To');
        data.addColumn('number', 'Weight');
        data.addRows([
          [ 'A', 'X', 5 ]
        ]);

        // Sets chart options.
        var options = {
          width: 600,
        };

        // Instantiates and draws our chart, passing in some options.
        var chart = new google.visualization.Sankey(document.getElementById('sankey_basic'));
        chart.draw(data, options);
      }
    </script>
     <div id="sankey_basic" style="width: 900px; height: 300px;"></div>
    <apex:tabPanel></apex:tabPanel> 
</apex:page>

Does anyone know how to fix that?
Hi, I've created a few classes and in order to make life easy, I've decided to create a package for ease of pushing the change over to my production org.

I've never tried this approach before, so I may be missing something.

I can confirm that all the classes and controllers pass with over 75% when testing in the developer console. However, when I try to upload the package, the average test coverage is only 57%

Why could that be happening?

I'd really rather not create a change set as the are are 6 custom objects at least...
/* class */

Global class emailHelper {
public static void sendEmail(ID recipient, ID candidate) {
//New instance of a single email message
Messaging.SingleEmailMessage mail =

            new Messaging.SingleEmailMessage();

  

// Who you are sending the email to

   mail.setTargetObjectId(recipient);

 

   // The email template ID used for the email

   mail.setTemplateId('');

           

   mail.setWhatId(candidate);   

   mail.setBccSender(false);

   mail.setUseSignature(false);

   mail.setReplyTo('recruiting@acme.com');

   mail.setSenderDisplayName('HR Recruiting');

   mail.setSaveAsActivity(false); 

 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

    } 

}

/* testclass */


@istest

public class emailHelpertest{

public static testmethod void testvalidate(){

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
User u = new User(Alias = 'test1', Email='test@gamil.com',FirstName = 'Test', 
            EmailEncodingKey='UTF-8', LastName='Testlast', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='test111@gmail.com');
            insert u;
ID candidate;
ID recipient;

Contact con=new Contact();
con.lastname='Testing';
insert con;

test.starttest();
//mail.setTemplateId('');
mail.setTargetObjectId(recipient);
mail.setWhatId(candidate);   
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setReplyTo('recruiting@acme.com');
mail.setSenderDisplayName('HR Recruiting');
mail.setSaveAsActivity(false); 
emailHelper ehelp=new emailHelper();
emailHelper.sendEmail(recipient,candidate);
test.stoptest();
}
}

But this test class has an error saying invalid id.It is able to cover only 41%.Please help.
How can we get campaigns from web and generate lead from those campaigns ?
Hello,

I have an object like below

Custom_Object_ABC__c (Object name)
CreatedBy
Owner
Custom_field1__c (Type number)

the above object will have many records (record1, record2, etc)

I wantt that the OWNER of record1 can modify or enter in field Custom_field1__c of record1,
similarlly, the OWNER of record2 can enter or modify the number in Custom_field1__c of record2

what are ways i could do it
Thank you for suggestion !
  • August 11, 2016
  • Like
  • 0
I have scheduled my certification exam on 8-August-2016.But in the middle of the exam it has been suspended automatically without any prior information.I have raised a case,but they didn't respond till date.Could any one suggest me how to proceed further.

Should I again book the slot by paying total amount,or will they reschedule it with amount with which I have booked slot before.

Thanks
Hiteshwar
Hello.

I have a customer's org into which I have installed a managed package.  On the org is some Apex code that calls a method in the managed package.  One of the things that the method does is make a SOQL select statement, but this fails saying "No such column".  However, if I run exactly the same SOQL statement outside of the managed package, it works.

Here is a sample of the code:
 
System.debug('HERE2: ' + [SELECT BillingAddress,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingAddress,Phone,Fax,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,OwnerId,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate,LastViewedDate,IsPartner,IsCustomerPortal FROM Account Where Id in :setaccountId]);
Account member = (Account)(XXXXXXX.Util.getSObjects(setAccountId)[0]);

This is the debug log:
 
16:25:15.8 (1244514753)|SOQL_EXECUTE_BEGIN|[49]|Aggregations:0|SELECT Id, IsDeleted, MasterRecordId, Name, Type, RecordTypeId, ParentId, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, BillingAddress, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingCountry, ShippingAddress, Phone, Fax, Website, Sic, Industry, AnnualRevenue, NumberOfEmployees, Ownership, TickerSymbol, Description, Rating, Site, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, LastViewedDate, IsPartner, IsCustomerPortal FROM Account WHERE Id = :tmpVar1
16:25:15.8 (1278032882)|SOQL_EXECUTE_END|[49]|Rows:1
16:25:15.8 (1278087443)|HEAP_ALLOCATE|[49]|Bytes:8
16:25:15.8 (1278113162)|HEAP_ALLOCATE|[49]|Bytes:524
16:25:15.8 (1278151757)|HEAP_ALLOCATE|[49]|Bytes:8
16:25:15.8 (1278378087)|HEAP_ALLOCATE|[49]|Bytes:651
16:25:15.8 (1278413071)|HEAP_ALLOCATE|[49]|Bytes:658
16:25:15.8 (1278443969)|USER_DEBUG|[49]|DEBUG|HERE2: (Account:{Id=0014E00000BAA5FQAX, IsDeleted=false, Name=Prasad Household, RecordTypeId=0124E0000004PsOQAU, BillingStreet=Bill1, BillingCity=Bill City, BillingState=State, BillingPostalCode=Postal, BillingCountry=UK, BillingAddress=API address [ Bill1, Bill City, State, Postal, UK, null, null, null, null, null], ShippingAddress=null, OwnerId=0054E000000L2viQAC, CreatedDate=2016-06-16 14:51:04, CreatedById=0054E000000L2viQAC, LastModifiedDate=2016-08-10 12:49:52, LastModifiedById=0054E000000L2p6QAC, SystemModstamp=2016-08-10 12:49:52, LastViewedDate=2016-08-10 14:43:09, IsPartner=false, IsCustomerPortal=true})
16:25:15.8 (1278457800)|STATEMENT_EXECUTE|[50]
16:25:15.8 (1288020530)|HEAP_ALLOCATE|[50]|Bytes:36
16:25:15.8 (1288035968)|HEAP_ALLOCATE|[50]|Bytes:159
16:25:15.8 (1288039088)|HEAP_ALLOCATE|[50]|Bytes:147
16:25:15.8 (1288069088)|METHOD_ENTRY|[1]|01p4E000000D3mS|Util.Util()
16:25:15.8 (1288073885)|STATEMENT_EXECUTE|[1]
16:25:15.8 (1288095397)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1288135086)|METHOD_EXIT|[1]|Util
16:25:15.8 (1288197449)|METHOD_ENTRY|[50]|01p4E000000D3mS|XXXXXX.Util.getSObjects(Set<Id>)
16:25:15.8 (1288210369)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1289170040)|ENTERING_MANAGED_PKG|XXXXXX
16:25:15.8 (1308239962)|SOQL_EXECUTE_BEGIN|[30]|Aggregations:0|SELECT Id,IsDeleted,MasterRecordId,Name,Type,RecordTypeId,ParentId,BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry,BillingAddress,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingAddress,Phone,Fax,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,OwnerId,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate,LastViewedDate,IsPartner,IsCustomerPortal FROM Account Where Id IN :p_Ids
16:25:15.8 (1309713440)|METHOD_EXIT|[50]|01p4E000000D3mS|XXXXXX.Util.getSObjects(Set<Id>)
16:25:15.8 (1309785853)|VARIABLE_SCOPE_BEGIN|[43]|Ex|Exception|true|false
16:25:15.8 (1309879374)|VARIABLE_ASSIGNMENT|[43]|Ex|"common.apex.runtime.impl.ExecutionException: No such column 'BillingAddress' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."|0x1a7353e4

As you can see, the code in the managed package does the same SOQL select, but fails.

Note that this managed package works fine in other orgs

I have tried raising a case with Salesforce, but was told it was a "Developer Support Issue".

Thanks,

Carl







 
  • August 11, 2016
  • Like
  • 0
Hi All,

I'm having a salesforce developer trial account.
I need  to integrate it with mule.When i'm trying to connect to the salesforce the error is shown as
" API not enabled for the organization"
Hi,

Could   you please explain me the "output panel " component  with simple example.

Regards,
Ram.
Can someone please guide me as how to make a single field mandatory in an integrated project where salesforce is backend and drupal is frontend.

Thanks inadvance.
The main requirement was to show a simple Bar graph in a Community Home Page (VF Page). I firstly tried to show a simple already created Report in Salesforce but got to know that Community doesn't allow access to Reports and you need a Community Plus license which is not possible.
Then I tool the second approach to create the Graphs manually where All I need to show is Case Types on the X Axis (Group Data Axis) and the Bar should Show the Number of Cases whose status are equal to "In Progress".
Therefore in the Controller Class I had the following method:
 
// To Calculate Number of Cases for status = 'In Progress'

       public class Types {

        public Integer cnt {get; set;}
        public String ty {get; set; }
        Types(String ty, Integer cnt) {
            this.cnt = cnt;
            this.ty = ty;
        }
    }

 public Types[] getTypes() {
           Types[] types = new Types[] {};

      for (AggregateResult ar : [SELECT COUNT(id) c, Type t FROM Case WHERE Status='In Progress' GROUP BY Type])
      {
        types.add(new Types (
        (String) ar.get('t'),
        (Integer) ar.get('c')
        ));
      }
       return types;
    }
And in the Visual Force Page I had the following:
 
<div style="padding: 15px;">
                              <label>Number of Enquirers in Progress</label>
                              <apex:chart height="380" width="400" data="{!Types}">
                                  <apex:legend position="right"/>
                                  <apex:axis type="Numeric" position="left" fields="cnt" title="Case Record Count"/>
                                  <apex:axis type="Category" position="bottom" fields="ty" title="Status" />
                                  <apex:barSeries title="In Progress Cases" orientation="vertical" axis="left" xField="ty" yField="cnt" />
                              </apex:chart>
                          </div>
But the above Code is not showing proper Bar graph. The Bars are not shown at all but I can see the x-axis and y-axis labels. I am new to Coding and have to fulfill this requirement as soon as possible. Also please let me know if there is any easier option for creating the Graphs. Any help will be appreciated.

 
My task is I need to count number of times a record has been edited using Edit button after record has been created. For this I created a field called Edit_Counting__c (Number Type) and also created one workflow on MapTesting__c to get the count that record has been edited using ISCHANGED (Field Type).
Later I created one more field called Counting__c and I created this trigger, assigned Edit_counting__c with Counting__c (maap.Counting__c = maap.Edit_Counting__c+1).
I am getting my output by using Counting__c value, but its working for only one record when I click edit button for one record respectively. When I am trying to update more than one record using developer console, the Counting__c value does not effect to all the modified records.
I do not know where I have done mistake. I also post my code below. Please check it and please could anyone help in this?
Thanks in advance
KS Kumaar
trigger MapTesting_Editable on MapTesting__c(after update) { List<MapTesting__c> mmp = new List<MapTesting__c>(); List<MapTesting__c> mm = [select id, Edit_Counting__c, Counting__c from MapTesting__c where Id IN: Trigger.OldMap.keySet()]; if (RecusrssionTrigger.flag) { for (MapTesting__c maap: mm) { RecusrssionTrigger.flag = false; maap.Counting__c = maap.Edit_Counting__c + 1; mmp.add(maap); } update mmp; } }
Hi

Can anyone please explain me how to use <apex:iInputHidden> with an example. I'm unable to understand working of this tag.

Sarvesh