• Marvin Castro 8
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
Hello.

I am fairly new to salesfroce and here's my scenario - I created a custom object to add to the Opportunity related list called Transactions - users enter the transaction data manually as part of a Proof of Concept.  The requirement is to carry over the related list with the associated data to the Contact object.  I can add the Transactions custom object as a related list in the Contact object with the associated fields; however, the data does not carry over.  Can you please assist in identifyig what I'm missing?

Thanks,

Marvin 
Hello, I am new to salesforce and writing my first Test Class.  I created this code in Dev and unable to push to production due needing to create a test class.  Below is the code.  

I appreciate the assistance.

Marvin

trigger changeLeadStatus on Task (before insert, before update) {
    String desiredNewLeadStatus = 'Working';

    List<Id> leadIds=new List<Id>();
    for(Task t:trigger.new){
        if(t.Status=='Completed'){
            if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead
                leadIds.add(t.whoId);
            }//if 2
        }//if 1
    }//for
    List<Lead> leadsToUpdate=[SELECT Id, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE];
    For (Lead l:leadsToUpdate){
        l.Status=desiredNewLeadStatus;
    }//for
    
    try{
        update leadsToUpdate;
    }catch(DMLException e){
        system.debug('Leads were not all properly updated.  Error: '+e);
    }
}//trigger

 
Hello.  I'm new to salesforce.  How do I create a trigger that will update the lead status to working when an activity is created (event, task, call)?  I saw this code while doing research, and it works for logging a call, but does not update the status if I schedule an event.  Any help will be appreciated.

trigger changeLeadStatus on Task (before insert, before update) {
    String desiredNewLeadStatus = 'Working';

    List<Id> leadIds=new List<Id>();
    for(Task t:trigger.new){
        if(t.Status=='Completed'){
            if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead
                leadIds.add(t.whoId);
            }//if 2
        }//if 1
    }//for
    List<Lead> leadsToUpdate=[SELECT Id, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE];
    For (Lead l:leadsToUpdate){
        l.Status=desiredNewLeadStatus;
    }//for
    
    try{
        update leadsToUpdate;
    }catch(DMLException e){
        system.debug('Leads were not all properly updated.  Error: '+e);
    }
}//trigger
 
Hi - I'm new to creating VF pages in salesforce.  I created a simple lead form that captures basic profile information.  I'm having issues with special character on the Company name and/or the city fields on the Lead object. It appears it doesn't save the record in this scenario - Company Name Re/Max Unlimited  City:  San Antonio

Here's the apex code for the page:

<apex:page standardController="Lead">
<apex:form >
    <apex:pageBlock mode="edit">
        <p/>
        <p/>
           <div align="center" draggable="false" >
        <apex:commandbutton action="{!save}" value="Save"/>
        <apex:commandbutton action="{!cancel}" value="Cancel"/>
        </div>
        <p/>
      
        <apex:pageBlockSection title="Lead Information" columns="1">
            <apex:inputField value="{!Lead.Salutation}"/>
            <apex:inputField value="{!Lead.FirstName}" required="true"/>
             <apex:inputField value="{!Lead.LastName}"/>
            <apex:inputField value="{!Lead.Suffix}"/>
            <apex:inputField value="{!Lead.Company}"/>       
 </apex:pageBlockSection>
 </apex:pageBlock>       
 <p/>
    <apex:pageBlock mode="edit">
        <apex:pageBlockSection title="Contact Information" columns="1">
                   <apex:inputField value="{!Lead.Email}" required="true"/>
                    <apex:inputField value="{!Lead.Phone}" required="true"/>
                    <apex:inputField value="{!Lead.MobilePhone}"/>
                    <apex:inputField value="{!Lead.Street}"/>
                    <apex:inputField value="{!Lead.City}" required="true"/>
                    <apex:inputField value="{!Lead.state}" required="true"/>
                    <apex:inputField value="{!Lead.postalcode}"/>
                    <p/>     
 </apex:pageBlockSection>
 </apex:pageBlock>   
</apex:form>
</apex:page>

I appreciate any assistance.

Thanks,

Marvin 
Hello.  I'm new to salesforce.  How do I create a trigger that will update the lead status to working when an activity is created (event, task, call)?  I saw this code while doing research, and it works for logging a call, but does not update the status if I schedule an event.  Any help will be appreciated.

trigger changeLeadStatus on Task (before insert, before update) {
    String desiredNewLeadStatus = 'Working';

    List<Id> leadIds=new List<Id>();
    for(Task t:trigger.new){
        if(t.Status=='Completed'){
            if(String.valueOf(t.whoId).startsWith('00Q')==TRUE){//check if the task is associated with a lead
                leadIds.add(t.whoId);
            }//if 2
        }//if 1
    }//for
    List<Lead> leadsToUpdate=[SELECT Id, Status FROM Lead WHERE Id IN :leadIds AND IsConverted=FALSE];
    For (Lead l:leadsToUpdate){
        l.Status=desiredNewLeadStatus;
    }//for
    
    try{
        update leadsToUpdate;
    }catch(DMLException e){
        system.debug('Leads were not all properly updated.  Error: '+e);
    }
}//trigger
 
Hi - I'm new to creating VF pages in salesforce.  I created a simple lead form that captures basic profile information.  I'm having issues with special character on the Company name and/or the city fields on the Lead object. It appears it doesn't save the record in this scenario - Company Name Re/Max Unlimited  City:  San Antonio

Here's the apex code for the page:

<apex:page standardController="Lead">
<apex:form >
    <apex:pageBlock mode="edit">
        <p/>
        <p/>
           <div align="center" draggable="false" >
        <apex:commandbutton action="{!save}" value="Save"/>
        <apex:commandbutton action="{!cancel}" value="Cancel"/>
        </div>
        <p/>
      
        <apex:pageBlockSection title="Lead Information" columns="1">
            <apex:inputField value="{!Lead.Salutation}"/>
            <apex:inputField value="{!Lead.FirstName}" required="true"/>
             <apex:inputField value="{!Lead.LastName}"/>
            <apex:inputField value="{!Lead.Suffix}"/>
            <apex:inputField value="{!Lead.Company}"/>       
 </apex:pageBlockSection>
 </apex:pageBlock>       
 <p/>
    <apex:pageBlock mode="edit">
        <apex:pageBlockSection title="Contact Information" columns="1">
                   <apex:inputField value="{!Lead.Email}" required="true"/>
                    <apex:inputField value="{!Lead.Phone}" required="true"/>
                    <apex:inputField value="{!Lead.MobilePhone}"/>
                    <apex:inputField value="{!Lead.Street}"/>
                    <apex:inputField value="{!Lead.City}" required="true"/>
                    <apex:inputField value="{!Lead.state}" required="true"/>
                    <apex:inputField value="{!Lead.postalcode}"/>
                    <p/>     
 </apex:pageBlockSection>
 </apex:pageBlock>   
</apex:form>
</apex:page>

I appreciate any assistance.

Thanks,

Marvin