• siva@shiva.com
  • NEWBIE
  • 75 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 13
    Replies
while adding campaign members into campaign i am getting following  error message "Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save requires that some subset of rows save without any errors in order to avoid inconsistent side effects from those triggers.'.
Note:existing Lead/contact records doesnot have manadatory fields. for hat i wrote validaition trigger.

<apex:inputtext value="{!gt.agreementdate}" size="12" onfocus="DatePicker.pickDate(false, this, false);"/>

i am creating Email Service class  my requirement is when task status is completed then email will sent to assign contact persion emai id...so.....i am new to Email service concept.please help me...here is my code

 

 

 

global class emailservice implements Messaging.InboundEmailHandler {

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

// Create an inboundEmailResult object for returning
// the result of the Force.com Email Service
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

     task te=[select id,status,whoid from task limit 1];
     Contact c=[select id,lastname,Account.Name,email  from contact where id=:te.whoid];
     String myPlainText = 'I spoke with '+c.lastname+ 'today from '+ '  '+c.account.name +'  '+'about the latest proposal.';

// Add the email plain text into the local variable

try
{
      myPlainText = email.plainTextBody.substring(0, email.plainTextBody.indexOf('<stop>'));
}
catch (System.StringException e)
{
     myPlainText = email.plainTextBody;
     System.debug('No <stop> in email: ' + e);
}

// Set the result to true, no need to send an email back to the user
// with an error message
  if(te.status=='completed')
  result.success = true;
  // Return the result for the Force.com Email Service
  return result;
}
}

how to handle SINGLE_EMAIL_LIMIT_EXCEEDED, Failed to send email

 

here is my code ...please check it

trigger createactivity on Task (before insert,after insert,before update,after update) {
if(trigger.isbefore)
{
    if (Trigger.isinsert) {
 
     for(task t:trigger.new){
      if(t.status=='completed'){
          sendmailto();    
       }
      }
    }

}

if(trigger.isafter){

if(trigger.isinsert)
{
 for(task t:trigger.new){
      if(t.status=='completed'){
       sendmailto();    
       }
      }
}
 if (Trigger.isupdate) {
 
     for(task t:trigger.old){
      if(t.status=='completed'){
       sendmailto();    
       }
      }
    }

}
public void sendmailto()
{
     Contact c=[select id,lastname,Account.Name,email  from contact limit 1];
     List<id> contactids;
     
     string []to=c.email.split(':',0);
     system.debug('************************************'+to);
     if(c.email<>null)
     {
     Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
     
     email.setToAddresses(to);
      //email.setTargetObjectId(c.id);  
      email.setSubject('this will be the task subject');
      email.setplainTextbody('I spoke with '+c.lastname+ 'today from '+c.account.name +'about the latest proposal.');
      messaging.sendemailresult[]r=messaging.sendemail(new messaging.singleemailmessage[]{email});
      }
          
       else
        {
            Messaging.SingleEmailMessage mail1 = new Messaging.SingleEmailMessage();
            String[]  toAddresses = new String[] {'sivasalesforce.com@gmail.com'};
            mail1.setToAddresses(toAddresses);
            mail1.setplainTextbody('Invalid mail id'+c.email);
            //Messaging.sendEmail(new Messaging.SingleEmailMessage [] {mail1});
            messaging.sendemailresult[]r=messaging.sendemail(new messaging.singleemailmessage[]{mail1});

       }
     
}
}

i am traing to send mail to contact email ....but it give an error....please help me

Here is my code .....i didnot pass id value from pageblocktable column (param tag) to apex class ... it gives null....value...so please help me...

 

 

<apex:page controller="approvalclass" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageblockTable value="{!data}" var="d">
<apex:column >
<apex:outputPanel >
<apex:commandButton action="{!approvalagent}" value="Approv">
<apex:param value="{!d.id}" name="{!passid}" assignTo="{!passid}"/>
</apex:commandButton>
<apex:commandButton action="{!rejectagent}" value="Regect">
<apex:param value="{!d.id}" assignTo="{!passid}" name="passid"/>
</apex:commandButton>
</apex:outputPanel>
</apex:column>
<apex:column value="{!d.Account__c}"/>
<apex:column value="{!d.State_Territory__c}"/>
<apex:column value="{!d.Policy_Types__c}"/>
<apex:column value="{!d.Policie_status__c}"/>
<apex:column value="{!d.State_Territory__c}"/>
<apex:column value="{!d.Commission_Rate__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

-------------------------

class

 

 

public with sharing class approvalclass {
public string passid { get; set; }
public list<policie__c> p=new list<policie__c>();
list<policie__c> pc=new list<policie__c>();
public approvalclass(){
passid= System.currentPageReference().getParameters().get('id');
system.debug('*********************************************'+passid);  }
    public PageReference rejectagent() {
    system.debug('*********************************************'+passid);
       pc=[select id,name,Maturity_Amount__c,Commission_Rate__c,Account__c,Policie_status__c,Policy_Types__c,Premium_Amount__c,State_Territory__c from policie__c];
   for(policie__c pt:pc )
   {
     if(pt.Commission_Rate__c!=null && pt.id==passid)
     pt.Approval_status__c='Reject';
     
          upsert pt;  
    }  
      return null;
    }


    public PageReference approvalagent() {
       system.debug('*********************************************'+passid);
   pc=[select id,name,Maturity_Amount__c,Commission_Rate__c,Account__c,Policie_status__c,Policy_Types__c,Premium_Amount__c,State_Territory__c from policie__c];
   for(policie__c pts:pc)
   {
      if(pts.Commission_Rate__c!=null && pts.id==passid)
       pts.Approval_status__c='approval';
    
      upsert pts;   
    }
    
        pagereference ref = new pagereference('https://ap1.salesforce.com'+passid);
        ref.setredirect(true);
        return ref;

 
 }

    public list<policie__c>getData() {
    p=[select id,name,Maturity_Amount__c,Account__c,Policie_status__c,Policy_Types__c,Premium_Amount__c,Commission_Rate__c,State_Territory__c from policie__c where ownerid=:userinfo.getuserid()];
    
        return p;
    }



}

Hi friends ,i am new to WSDL ,so Please give me on example on Rest API or SOAP API .its very helpfull for me.................

can we pass object dynamically from vf to apex...?

like

.....

[select id,name from account]

 

insted of account object we are going pass objects //

 

 

is it possible...?

It gives an error .........like this

 

Error: DObjDisplay Compile Error: The property String objNames is referenced by Visualforce Page (getobjectsinorganization) in salesforce.com. Remove the usage and try again. at line 6 column 17

 

<apex:page sidebar="false" controller="DObjDisplay">
 <apex:form >
     ObjectNames:
     <apex:selectlist multiselect="false" size="1">
         <apex:selectOptions value="{!objNames}">
         </apex:selectOptions>
     </apex:selectlist>
 </apex:form>
</apex:page>

 

 

public with sharing class DObjDisplay {
//Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
List<SelectOption> options = new List<SelectOption>();
 

 
public List<SelectOption> getobjNames()
 {

  List<Schema.SObjectType> gdd = Schema.getGlobalDescribe().Values();    
 
  for(Schema.SObjectType f : gdd)
   {
      options.add(new SelectOption(f.getDescribe().getName(),f.getDescribe().getName()));
   }

 return options;
}

}

just i want to retrive month from dateofbirth field ...please help me

hi

 

 

<apex:page Controller="gmails" >

<script type="text/javascript">
function addFile(b) {
if (b && b.parentNode &&b.parentNode.insertBefore &&document.createElement) {
var fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.name = 'filename2[]';

b.parentNode.insertBefore(fileInput, b);

b.parentNode.insertBefore(document.createElement(' br'), b);
}
}
</script>
 
 
  <script type="text/javascript">
    function generatenew()
{
var d=document.getElementById("div");
d.innerHTML="<p><input type='text' name='food'>";
}
</script>
<apex:form >


 <apex:pageblock title="Mailing to the" >
  <apex:pageblocksection columns="1">
  <apex:outputLabel value="Email ID" for="subject4"/>
  <apex:inputtext value="{!emails}"  id="subject4"/><br/>
 
 <apex:outputLabel value="subject" for="subject3"/>
 <apex:inputtext value="{!subject}"  id="subject3"/><br/>
 
 <apex:pageblockSectionItem >
 <apex:outputLabel value="attachment"  for="attachfile"/>
 <input type="file" name="filename2[]" id="attachfile"/>
 <input type="button" value="Add another file" onclick="addFile(this);"/>
</apex:pageblockSectionItem>


 
 <apex:outputLabel value="body" for="subject3"/>
 <apex:inputtextarea value="{!body}" rows="10"  cols="100"/>
 </apex:pageblocksection>
 <apex:commandButton value="send email" action="{!send}"/>
 
 </apex:pageblock>
 </apex:form>
</apex:page>

 

---------------------------

class

public with sharing class gmails
{
public string subject{get; set;}
public string body{get;set;}
public string emails{get;set;}
public Attachment attachment{get;set;}


public gmails()
{
}


public pagereference send()
{
string []to=emails.split(':',0);

/*List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        for (Attachment a : [select Name,Body,BodyLength from Attachment where ParentId=:attachment.parentid])
        {  // Add to attachment file list  
            Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();  
            efa.setFileName(a.Name);
            efa.setBody(a.body);
            fileAttachments.add(efa);
        }
        
    */    
        
        
 /*     Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        // Reference the attachment page and pass in the account ID
        Integer numAtts=[SELECT count() FROM attachment];
        system.debug('Number of Attachments Atts = '+ numAtts);
        List<Attachment> allAttachment = new List<Attachment>();
        allAttachment = [SELECT Id, Name, ContentType, Body FROM Attachment];
        // Create the email attachment
        //List<Messaging.Emailfileattachment> efa = new List<Messaging.Emailfileattachment>();
        Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
        
        if(numAtts > 0){
                for (Integer i = 0; i < numAtts; i++){
                    system.debug(allAttachment[i].Name);
                    efa.setFileName(allAttachment[i].Name);
                    efa.setBody(allAttachment[i].Body);
                    efa.setContentType(allAttachment[i].ContentType);
                }
        }
      */
    
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setsubject(subject);
//email.setFileAttachments(fileAttachments);


//email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
      
email.setToAddresses(to );
email.setplaintextbody(body);
messaging.sendemailresult[]r=messaging.sendemail(new messaging.singleemailmessage[]{email});
return null;
}

 
}

 

 

here i am getting run time error  please try this.

Hi friends,

 

I want account object related contact display in pdf format and the contact should be display in barcode image and also the images chages bynamically

 

 

i created visual force page ,in that i need background image in css file .it does not invoke .please help me .

i created vf page with registration object fields .and  when we are entering data in that object .automatically  email will send .

but vf does not  send .please help me.the vf page must  contains objects fields.

<apex:inputtext value="{!gt.agreementdate}" size="12" onfocus="DatePicker.pickDate(false, this, false);"/>

i am traing to send mail to contact email ....but it give an error....please help me

Here is my code .....i didnot pass id value from pageblocktable column (param tag) to apex class ... it gives null....value...so please help me...

 

 

<apex:page controller="approvalclass" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageblockTable value="{!data}" var="d">
<apex:column >
<apex:outputPanel >
<apex:commandButton action="{!approvalagent}" value="Approv">
<apex:param value="{!d.id}" name="{!passid}" assignTo="{!passid}"/>
</apex:commandButton>
<apex:commandButton action="{!rejectagent}" value="Regect">
<apex:param value="{!d.id}" assignTo="{!passid}" name="passid"/>
</apex:commandButton>
</apex:outputPanel>
</apex:column>
<apex:column value="{!d.Account__c}"/>
<apex:column value="{!d.State_Territory__c}"/>
<apex:column value="{!d.Policy_Types__c}"/>
<apex:column value="{!d.Policie_status__c}"/>
<apex:column value="{!d.State_Territory__c}"/>
<apex:column value="{!d.Commission_Rate__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

-------------------------

class

 

 

public with sharing class approvalclass {
public string passid { get; set; }
public list<policie__c> p=new list<policie__c>();
list<policie__c> pc=new list<policie__c>();
public approvalclass(){
passid= System.currentPageReference().getParameters().get('id');
system.debug('*********************************************'+passid);  }
    public PageReference rejectagent() {
    system.debug('*********************************************'+passid);
       pc=[select id,name,Maturity_Amount__c,Commission_Rate__c,Account__c,Policie_status__c,Policy_Types__c,Premium_Amount__c,State_Territory__c from policie__c];
   for(policie__c pt:pc )
   {
     if(pt.Commission_Rate__c!=null && pt.id==passid)
     pt.Approval_status__c='Reject';
     
          upsert pt;  
    }  
      return null;
    }


    public PageReference approvalagent() {
       system.debug('*********************************************'+passid);
   pc=[select id,name,Maturity_Amount__c,Commission_Rate__c,Account__c,Policie_status__c,Policy_Types__c,Premium_Amount__c,State_Territory__c from policie__c];
   for(policie__c pts:pc)
   {
      if(pts.Commission_Rate__c!=null && pts.id==passid)
       pts.Approval_status__c='approval';
    
      upsert pts;   
    }
    
        pagereference ref = new pagereference('https://ap1.salesforce.com'+passid);
        ref.setredirect(true);
        return ref;

 
 }

    public list<policie__c>getData() {
    p=[select id,name,Maturity_Amount__c,Account__c,Policie_status__c,Policy_Types__c,Premium_Amount__c,Commission_Rate__c,State_Territory__c from policie__c where ownerid=:userinfo.getuserid()];
    
        return p;
    }



}

Hi friends ,i am new to WSDL ,so Please give me on example on Rest API or SOAP API .its very helpfull for me.................

can we pass object dynamically from vf to apex...?

like

.....

[select id,name from account]

 

insted of account object we are going pass objects //

 

 

is it possible...?

It gives an error .........like this

 

Error: DObjDisplay Compile Error: The property String objNames is referenced by Visualforce Page (getobjectsinorganization) in salesforce.com. Remove the usage and try again. at line 6 column 17

 

<apex:page sidebar="false" controller="DObjDisplay">
 <apex:form >
     ObjectNames:
     <apex:selectlist multiselect="false" size="1">
         <apex:selectOptions value="{!objNames}">
         </apex:selectOptions>
     </apex:selectlist>
 </apex:form>
</apex:page>

 

 

public with sharing class DObjDisplay {
//Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
List<SelectOption> options = new List<SelectOption>();
 

 
public List<SelectOption> getobjNames()
 {

  List<Schema.SObjectType> gdd = Schema.getGlobalDescribe().Values();    
 
  for(Schema.SObjectType f : gdd)
   {
      options.add(new SelectOption(f.getDescribe().getName(),f.getDescribe().getName()));
   }

 return options;
}

}

just i want to retrive month from dateofbirth field ...please help me

hi

 

 

<apex:page Controller="gmails" >

<script type="text/javascript">
function addFile(b) {
if (b && b.parentNode &&b.parentNode.insertBefore &&document.createElement) {
var fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.name = 'filename2[]';

b.parentNode.insertBefore(fileInput, b);

b.parentNode.insertBefore(document.createElement(' br'), b);
}
}
</script>
 
 
  <script type="text/javascript">
    function generatenew()
{
var d=document.getElementById("div");
d.innerHTML="<p><input type='text' name='food'>";
}
</script>
<apex:form >


 <apex:pageblock title="Mailing to the" >
  <apex:pageblocksection columns="1">
  <apex:outputLabel value="Email ID" for="subject4"/>
  <apex:inputtext value="{!emails}"  id="subject4"/><br/>
 
 <apex:outputLabel value="subject" for="subject3"/>
 <apex:inputtext value="{!subject}"  id="subject3"/><br/>
 
 <apex:pageblockSectionItem >
 <apex:outputLabel value="attachment"  for="attachfile"/>
 <input type="file" name="filename2[]" id="attachfile"/>
 <input type="button" value="Add another file" onclick="addFile(this);"/>
</apex:pageblockSectionItem>


 
 <apex:outputLabel value="body" for="subject3"/>
 <apex:inputtextarea value="{!body}" rows="10"  cols="100"/>
 </apex:pageblocksection>
 <apex:commandButton value="send email" action="{!send}"/>
 
 </apex:pageblock>
 </apex:form>
</apex:page>

 

---------------------------

class

public with sharing class gmails
{
public string subject{get; set;}
public string body{get;set;}
public string emails{get;set;}
public Attachment attachment{get;set;}


public gmails()
{
}


public pagereference send()
{
string []to=emails.split(':',0);

/*List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        for (Attachment a : [select Name,Body,BodyLength from Attachment where ParentId=:attachment.parentid])
        {  // Add to attachment file list  
            Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();  
            efa.setFileName(a.Name);
            efa.setBody(a.body);
            fileAttachments.add(efa);
        }
        
    */    
        
        
 /*     Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        // Reference the attachment page and pass in the account ID
        Integer numAtts=[SELECT count() FROM attachment];
        system.debug('Number of Attachments Atts = '+ numAtts);
        List<Attachment> allAttachment = new List<Attachment>();
        allAttachment = [SELECT Id, Name, ContentType, Body FROM Attachment];
        // Create the email attachment
        //List<Messaging.Emailfileattachment> efa = new List<Messaging.Emailfileattachment>();
        Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
        
        if(numAtts > 0){
                for (Integer i = 0; i < numAtts; i++){
                    system.debug(allAttachment[i].Name);
                    efa.setFileName(allAttachment[i].Name);
                    efa.setBody(allAttachment[i].Body);
                    efa.setContentType(allAttachment[i].ContentType);
                }
        }
      */
    
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setsubject(subject);
//email.setFileAttachments(fileAttachments);


//email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
      
email.setToAddresses(to );
email.setplaintextbody(body);
messaging.sendemailresult[]r=messaging.sendemail(new messaging.singleemailmessage[]{email});
return null;
}

 
}

 

 

here i am getting run time error  please try this.

i created visual force page ,in that i need background image in css file .it does not invoke .please help me .

i created vf page with registration object fields .and  when we are entering data in that object .automatically  email will send .

but vf does not  send .please help me.the vf page must  contains objects fields.