• Prabhat Kumar12
  • SMARTIE
  • 670 Points
  • Member since 2015
  • NIIT


  • Chatter
    Feed
  • 20
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 107
    Replies
Hi all, I have the following code:
 
global class ProcessLinkBetweenWorlds implements Database.Batchable<sObject>, Database.Stateful {
     
    global List<Account> accountList = new List<Account>();

    global Database.QueryLocator start(Database.BatchableContext bc) {
        
        accountList =  [Select PersonContactId, concat_ID__c, PersonEmail, Name FROM Account 
                       WHERE PersonEmail != NULL AND FirstName != NULL AND IsPersonAccount = TRUE 
            	       AND PersonMailingCountry != 'United Kingdom' AND Is_Master_Record__c = True]; // THIS QUERY IS TOO LARGE
		
        Set<String> accountConcatIds = new Set<String>();
        for(Account a: accountList) 
        {
            accountConcatIds.add(a.Concat_ID__c);
        }
        
        return Database.getQueryLocator(
                'SELECT ContactId, SuppliedEmail, concat_ID__c From Case ' + 
                'WHERE ContactId = NULL AND SuppliedEmail = NULL AND  Concat_ID__c IN :  accountConcatIds'
        );    
    }
     
    global void execute(Database.BatchableContext bc, List<Case> scope){
        System.Debug(accountList.Size() + '|' + scope.Size());
        for(Case c : scope) {
            for(Account a : accountList ) {
                
                if(a.Concat_Id__c == c.Concat_ID__c) {
                    // Match Found!
                }
            }
        }
    }    
    
    global void finish(Database.BatchableContext bc){
       
    }    
}

How can I make the accountList work inside the context of the batch? I would like to compare both lists for a match. Any other optimizations and improvements would be appreciated. 
HI All,

What is a Queueable apex and explain with example program?
Give an example for Chaining queueable apex & execution?
 
I wrote a trigger on the User object on the after inserted and after updated events. The trigger fires on the inset event, but not on the update event. I wrote a test class to verify and the same thing happened. Any ideas as to why? I don't see any solutions on this topic.
Hi all,

Do you know how we can increase the number of characters of the the help text on a Custom field?

Thanks in advance.
Hi,

I am new to Salesforce. I have done some customization/coding in trail organization. Now i want to move this customization to another trail organization of salesforce. Pls guide me the steps for the same.

Regards,
Harshit Vyas
Hi All,

I have a doubt regarding displaying merge fields on Email template. I want to display event activityDate and Event ActivityDateTime related to Lead object in an Email Template. I have written the merge fields like below:

Your appointment Date and Time is listed below: 
{!Event.ActivityDate} 
{!Event.ActivityDateTime}


But it is not working when sending a demo email. It is an urgent requirement. Please provide a solution for this. 

Thanks in advance.
I am having a small issue populating 2 fields in my custom button, everything else seems to work fine but the account field does not populate anything and I cannot populate a user in the account contact field.  comments by the problem areas. code:
 
/setup/ui/recordtypeselect.jsp?ent=01I3B0000008YRp&
retURL=%2F{!Opportunity.Id}&
save_new_url=%2Fa2C%2Fe%3F{!Opportunity.Name}
accid={!Opportunity.Id}&
CF00N3B000000OKFI={!Opportunity.Primary_Contact__c}&
CF00N3B000000OKFI_lkid={!Opportunity.Primary_Contact__c.UserId}&//not sure how to reference the user id here?
CF00N3B000000OKFz={!Opportunity.Name}&
CF00N3B000000OKFz_lkid={!Opportunity.Id}&
CF00N3B000000OKFB ={!Opportunity.Account}&//this field is left blank, but these references work in any other field i assign them to
CF00N3B000000OKFB_lkid={!Opportunity.AccountId}&
00N3B000000OKFR={!Today()+90}&
Name=Quote For {!Opportunity.Name}

and in fact i would rather have the primary user in the related list Contact Roles as the Account contact.  Any help is greatly appreciated!
Hi,
I have created a Visual force email template related to opportunity. I want to show last 2 activities realted to opportunity in this email template.
But as per my code it is showing all activities related to opportunty.
How can i restrict number of avtivities show on the page.

here is my code:

<messaging:emailTemplate subject="Stage  change reminder" recipientType="User" relatedToType="Opportunity">
 <messaging:htmlEmailBody >
  <html>
    <body>
        <h1 style="font-size:100%">
        <p>Dear {!recipient.name},</p></h1>
      
        <p>FYI, appended below is a snapshot of the last few activities related to this opportunity:</p>
            <table border="3" style="width:100%">
             
                <tr>
                    <th>View Activity</th>
                    <th>ActivityDate</th>
                    <th>Subject</th>
                    <th>Status</th>
                </tr>
          
                <apex:repeat var="cx" value="{!relatedTo.ActivityHistories}">
                <tr>
                    <td><a href = "https://ap2.salesforce.com/{!cx.id}">View</a></td>
                    <td>{!cx.ActivityDate}</td>
                    <td>{!cx.Subject}</td>
                    <td>{!cx.Status}</td>
                </tr>
                </apex:repeat>
            </table>
            
            <p> Thank You</p>
            <p> Salesforce Team </p>
           
    </body>

  </html>
 </messaging:htmlEmailBody>
</messaging:emailTemplate>

Plz help me to show only last 2 activities.

Regards
Russell
Hello,

have a custom object called Bookings in our org.
This is fed off the opportunities and we have a current custom button that is called "modify order".

This button triggers a workflow email as well another workflow to check modify order as true.

Because we have a javascript code that pops up a window, it is not showing any validation rule even though I put this logic check below
Underlined



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

try { 

// identify the record 
var o = new sforce.SObject("Booking__c"); 
o.id = "{!Booking__c.Id}"; 

// make the field change 
o.Modify_Order__c= "TRUE"; 

// save the change 
var resulto = sforce.connection.update([o]); 

if(resulto[0].success=='true'){ 
alert('Your Order has been Submitted for Modification'); 
location.reload(); 

else { 
var errors = resulto[0].errors; 
var errorMessages = "An error has occurred, please contact your Salesforce Administrator"; 

for ( var i = 0; i < errors.length; i++ ) { 
errorMessages += errors[i].message + '\n'; 


alert( errorMessages ); // display all validation errors 



} catch ( ex ) { 

alert( ex ); // display any javascript exception message 

}
Hi ,
Please can  anyone help me ,

I am trying to do this project in Trailhead.
Build a Conference Management AppCreating an Apex class ,but I get this error while verification.

This is the ERROR:

 There was an unexpected error in your org which is preventing this assessment check from completing: System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Either the plain text body or html body must be supplied.: [] 
Note: you may run into errors if you've skipped previous steps.

 
Hi All,

Can you please provide me the Salesforce Integration meterials with examples. 

Thnaks in Advance!
Hello,
 I want to use Email service in salesforce so that when  i send mail through gmail then lead gets created in salesforce i tried it its working fine but i want to send gmail in specific format then it send me exception.

Please help me to fix out this issue..
global class CreateTaskEmailExample implements Messaging.InboundEmailHandler {
 global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email,Messaging.InboundEnvelope env){

    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
    
     Lead[] newLead = new Lead[0];
         String myPlainText= ''; 
    	myPlainText = email.plainTextBody; 
    // String firstName = email.fromname.substring(0,email.fromname.indexOf(' '));
     //String lastName = email.fromname.substring(email.fromname.indexOf(' '));
     //String Emailaddress = env.fromAddress;
       String strEmailId = email.fromAddress;
      
    system.debug('email.fromAddress'+strEmailId);
     String[] emailBody = email.plainTextBody.split('\n', 0);
      String firstName;
     String lastName; 
      String jobtitle;
      String city;
      String CompanyName;
      String Notes;
      String url;  
      String[] url2;
      Integer i;
      list<String> newlist=new list<String>();
     String textBody = email.plainTextBody;
    	String blank = '';
	 String nullString = null;
	 String whitespace = '  ';
      
     //list<String> newlist=new list<String>();
     //String firstName; // insert code here
    /* Integer index = -1;
	for (Integer j=0;j<emailBody[j].length;j++) {
    if (emailBody[j].equals(firstName)) {
        index = j;
        break;
    }
	}*/
	
     
  if(emailBody.size()>0 && emailBody[0]!=null && emailBody[0]!='')
     {
     	//System.assert(!String.isNotBlank(blank));
		//System.assert(!String.isNotBlank(nullString));
		//System.assert(!String.isNotBlank(whitespace));
     	firstName = emailBody[0].substring(11);
      system.debug('emailBody[0].substring(11)'+emailBody[0].substring(11));
     } 
    if(emailBody.size()>1 && emailBody[1]!=null && emailBody[1]!='')
     {
     lastName = emailBody[1].substring(5);
     system.debug('emailBody[1].substring(10)'+emailBody[1].substring(10));
      }
    if(emailBody.size()>2 && emailBody[2]!=null && emailBody[2]!='')
      {
   /*if(textBody.indexOf('Job Title:') > -1) {
                Integer startPos = textBody.indexOf('Job Title:');
                Integer endPos = textBody.indexOf('.',textBody.indexOf('Job Title:'));
                jobtitle = textBody.substring(startPos+'Job Title:'.length(),endPos);
                jobtitle = emailBody[2].substring(10);
            }*/
     jobtitle = emailBody[2].substring(10);
     system.debug('emailBody[2].substring(10)'+emailBody[2].substring(10));
      }
    if(emailBody.size()>3 && emailBody[3]!=null && emailBody[3]!='')
      {
      	/*if(textBody.indexOf('Company Name:') > -1) {
                Integer startPos = textBody.indexOf('Company Name:');
                Integer endPos = textBody.indexOf('.',textBody.indexOf('Company Name:'));
                companyName = textBody.substring(startPos+'Company Name:'.length(),endPos);
                CompanyName = emailBody[3].substring(10); 
            }*/
      CompanyName = emailBody[3].substring(10); 
     system.debug('emailBody[3].substring(10)'+emailBody[3].substring(10));
      }
    if(emailBody.size()>4 && emailBody[4]!=null && emailBody[4]!='')
      {
      	/*if(textBody.indexOf('City:') > -1) {
                Integer startPos = textBody.indexOf('City:');
                Integer endPos = textBody.indexOf('.',textBody.indexOf('City:'));
                city = textBody.substring(startPos+'City:'.length(),endPos);
                city = emailBody[4].substring(5);
            }*/
      city = emailBody[4].substring(5);
      system.debug('emailBody[4].substring(5)'+emailBody[4].substring(5));
      }
     if(emailBody.size()>5 && emailBody[5]!=null && emailBody[5]!='')
      {
      /*if(textBody.indexOf('Notes:') > -1) {
                Integer startPos = textBody.indexOf('Notes:');
                Integer endPos = textBody.indexOf('.',textBody.indexOf('Notes:'));
                Notes = textBody.substring(startPos+'Notes:'.length(),endPos);
               Notes = emailBody[5].substring(6);
            }*/
       Notes = emailBody[5].substring(6);
       system.debug('emailBody[5].substring(6)'+emailBody[5].substring(6));
      }
    for( i=6; i<100;i++){
    
   if(emailBody.size()==i){
      system.debug(i);
             break;
     } 
     
      if(emailBody[i]!=null && emailBody[i]!='')
      {
      system.debug(i);
      system.debug(emailBody.size());
       url = emailBody[i].substring(3);
       system.debug('emailBody[i].substring(6)'+emailBody[i].substring(6));
       //url1 = emailBody[6].substring(4);
       url2 = url.split('/n');      
      // system.debug(url);
       system.debug(url);  
          system.debug(url2); 
         
          newlist.add('<a href="'+url+'">'+url+'</a><br/>');
          system.debug('newlist'+newlist);
      }
    }  
    
   // String strSubject = email.subject;
   // String myText=email.plainTextBody;
    //String myFromName = email.fromName;
    
    Lead[] leads = [SELECT Id, Name, Email,City , Title,Company,Description FROM Lead WHERE Email = :email.fromAddress];
   try{
      newLead.add(
      new Lead(
      Email = strEmailId,
      FirstName=firstName,
      LastName=lastName,
      City =city,
      Title=jobtitle ,
      Company=companyName,
      Description=Notes,
      URL__c=String.valueOf(newlist)));
      insert newLead;    
      System.debug('New Lead record: ' + newLead );   
    } 
   catch (System.DmlException e)
    {
      System.debug('Incoming email duplicates existing Lead record(s): ' + leads );    
    }
    
      result.success = true;
    return result;
    
 }

}

now its giving me output in this way..

First Name: vishu21
Last Name: Kashyap
Job Title:  Developer
Company Name :TMC
City: Noida
Notes:testing data
 
url:http://www.unisteeltech.com/solutions/fasteners.html
      http://www.unisteeltech.com/solutions/fasteners.html

But i want to see my output in this format.

Name
        Carrie Santi DeLucchi
Email
        carriesanti@gmail.com<mailto:carriesanti@gmail.com>
Job Title
        Web Developer
Company Name
        Peak Interactive
City
        Oakland
Notes
        This is a test of the 3D printing form.
Attach your files here


  *   whats-happening-drop-down.jpg<http://3dprinting.uct.com/wp-content/uploads/gravity_forms/1-94a0761c56774dc9cb019cf78434661e/2015/09/whats-happening-drop-down.jpg>

Means it firstly search for 'Name' which is start position and Email which is anywhere in email body as end position like wise for all others..
Please help me to fix out this issue.
Hi All,

I am having below trigger which calls a method "sendNotification" when the account name is changed. I want this trigger to call the method when the account is deleted ie)on before delete operation. Please help me on how this can be done.
trigger Contactcallout2 on Account(after update) {
List<Contact> ListContact = new List<Contact>();
Set<ID> acctIds = new set<ID>();
    for(Account acct : trigger.new) {
        if(Trigger.oldMap.get(acct.id).Name != acct.Name){
             acctIds.add(acct.Id);      
    }
    }
    if(acctIds.size() > 0){
        for(Contact con : [SELECT id,Email,FirstName,LastName,phone,Title__c,Account.Name,status__c, AccountId FROM Contact WHERE AccountId IN : acctIds AND RecordTypeid = '012D6765454BaFA']){
          WebServiceCallout.sendNotification(con.Id,con.Email,con.FirstName,con.LastName,con.phone,con.Title__c,con.Account.Name,con.status__c);
        }
    }
   }
Many Thanks in advance
Abraham
 
I'm not a developer, but I inherited a class from a prior developer that needs a minor tweak to the production code. I've made the change in the sandbox code, but can't deploy to prod because of coverage issues that were apparently not worked out by the prior developer. Based on what I've read, it appears that the best approach is to refresh the sandbox, try to increase coverage and try to deploy again. Two questions:

1) What happens when a developer sandbox is refreshed - is data deleted or is the metadata changed to match the prod environment while data is maintained?
2) Is there a way to backup the sandbox before refreshing?

Any help would be appreciated.
Thanks.
 
Hi all. Learning Apex here. Refere to code and question below:

Code:
public class myClass {
   static final Integer PRIVATE_INT_CONST;
   static final Integer PRIVATE_INT_CONST2 = 200;
   public static Integer calculate () {
          return 2 + PRIVATE_INT_CONST2;
   }
   static {
         PRIVATE_INT_CONST = calculate ();
   }

}

Trying to get this code [ see code below] to (run in Execute Anonymous and ) return what I think should be '202'.  At first I tried to run this code and added System.debug (PRIVATE_INT_CONST); and the error was that only top level class variables can be declared static. [ What is a top level class? Is this just an outer classs?] So I created the class as a new class. Now that the class is created, it seems that it is reconizing it. So I simply entered System.debug(myClass.PRIVATE_INT_CONST); in the Execute Anonymous window and the error is that the variable is not visible. Can anyone help me correct the code so that it will run? What am I doing wrong? Thanks! 

 
Hi All,

i want to send email every day 4 pm. for that i written some code.
Please check it below code once and let me know, what i have to do.
 
global class scheduledEmail implements Schedulable {

    public static String CRON_EXP = '0 20 16 * * * *';

    global static String scheduleIt() {
        scheduledEmail sm = new scheduledEmail();
        return System.schedule('Monthly Email', CRON_EXP, sm);
    }
    
   global void execute(SchedulableContext SC) {
   
      sendmail();
      
   }
   public void sendmail()
       {
           Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
           string [] toaddress= New string[]{'sircilla.rakesh7@gmail.com'};
           email.setSubject('Testing Apex Scheduler-Subject');
           email.setPlainTextBody('Testing Apex Scheduler-Body');
           email.setToAddresses(toaddress);
           Messaging.sendEmail(New Messaging.SingleEmailMessage[]{email});
       }
}

Please explain step by step.
I appriciate your response.


Thank you.
Rakesh.S
Hi

I need to have a dynamic query to retrieve the fields in Campaign object (keeping aside the governace limit) but when i execute a sample query with all the fields in query editor I see an error "No such column 'hierarchyactualcost' on entity 'Campaign'."

when i set this field as visible for profile and then execute the query i do not see this error. Any ways on how to fix this so that i can perform the query without any errors?

the code to get the fields from the object is:

        Map <String, Schema.SObjectField> objectFields = Campaign.getSobjectType().getDescribe().fields.getMap();
        for (SObjectField fld : objectFields.values()) {
            query += ' ' + fld + ', ';
        }

is there a way to see if the field is set as not visible and if so then do not consider the field in the query?