• Sunadmin
  • NEWBIE
  • 25 Points
  • Member since 2009

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

i have web to lead page that includes some javascript code used to validate email addresses and verify all fields are filled out. the page routes to a record type but when the javascript validation is included it blocks the routing. 

here is the HTML that includes the javascript that references the validation code:

<form name="information" action= "https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" onsubmit="return validateForm();” >
 

when i take out 'onsubmit="return validateForm();” ' the information is routed to the correct record type but it wont validate the email or that the fields are filled out. the javascript code is accessed by this command.

 

here is the javascript code:

<script>
function validateForm()
{
var x=document.forms["information"]["first_name"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
var x=document.forms["information"]["last_name"].value;
if (x==null || x=="")
{
alert("Last name must be filled out");
return false;
}
var x=document.forms["information"]["email"].value;
if (x==null || x=="")
{
alert("Email must be filled out");
return false;
}
var x=document.forms["information"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
var x=document.forms["information"]["confirm_email"].value;
if (x==null || x=="")
{
alert("Confirm email must be filled out");
return false;
}
var x=document.forms["information"]["email"].value;
var pass= document.getElementById("email").value
var confPass = document.getElementById("confirm_email").value
if(pass != confPass) {
alert('Email fields do not match');
return false;
}
var x=document.forms["information"]["company"].value;
if (x==null || x=="")
{
alert("Company must be filled out");
return false;
}
var x=document.forms["information"]["state"].value;
if (x==null || x=="")
{
alert("State/Province must be filled out");
return false;
}
}

</script>

 

 

Hello,

 

I am working on an idea for a trigger and thought I would post this to the community before I get too far and realize it is not a worthwhile pursuit. Any feedback would be appreciated.

I am proposing a trigger that fires on a custom field to query email and two other custom fields “credit_line_request_Amount_c” and “credit_analysis_c” from Opportunity.

There are different stages to the trigger depending on the dollar amount in “credit_line_request_Amount_c” and if the potential customer was denied or approved per “credit_analysis_c”. Depending on the stage and status an email message will be sent out to the proper user.

I can say my first problem is that I am trying to query the email field from Opportunity. I am trying to talk the credit people into querying from Lead.

Here is my code so far, please excuse some of the pseudo code I have used and any syntax/compile errors, I am still in the planning stages.  

//APEX TRIGGER AND SOQL QUERY TO AUTOMATE PROCESS FROM CREDIT PERSON //DENY/APPROVE AND SEND EMAIL . MUST INCLUDE DATE/TIME OF APPROVE/DENY. 

Trigger denyapprove on Opportunity(after insert, before update){

    //resets trigger after each check
    Set Trigger<> = new Trigger{};
    for (Integer i=0; i<Trigger.new.size();i++) {

     //date time stamp for each check 
    for (credit_line_request_Email_c i : Trigger.new) {
                DateTime now = System.now();         
       
//SOQL Query for data
if(credit_line_request_Amount_c.size()!=0)
    List<Opportunity>=[SELECT credit_line_request_Amount_c, credit_analysis_c, Email    
    FROM Opportunity WHERE Record Type = Credit Approval);

//if stage 2 and credit denied  
if (credit_line_request_Amount_c()!<75,000) && (credit_analysis_c = 'deny';)
//this will need to be picklist field
    {
    //send email message to director
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(Credit Application Declined[0],Email);
    mail.setReplyTo.(director[0],Email);
    Messaging.sendEmail(new Messaging.Email Message[] {mail});
}
//if stage 2 and credit approved
if (credit_line_request_Amount_c()!<75,000) && (credit_analysis_c = 'approved';)
    {
    //send email message to applicant
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(approved[0],Email);
    mail.setReplyTo.(applicant[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}

//if stage 4 and credit denied  
if (credit_line_request_Amount_c()!>=75,000 && <125,000) && (credit_analysis_c = 'deny';)
    {
    //send email message to director
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(Credit Application Declined[0],Email);
    mail.setReplyTo.(director[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}
//if stage 4 and credit approved
if (credit_line_request_Amount_c()!>=75,000 && <125,000) && (credit_analysis_c = 'approved';)
    {
    //send email message to applicant
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(approved[0],Email);
    mail.setReplyTo.(applicant[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}

//if stage 5 and credit denied  
if (credit_line_request_Amount_c()!>=125,000 && <200,000) && (credit_analysis_c = 'deny';)
    {
    //send email message to director
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(Credit Application Declined[0],Email);
    mail.setReplyTo.(director[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}
//if stage 5 and credit approved
if (credit_line_request_Amount_c()!>=125,000 && <200,000) && (credit_analysis_c = 'approved';)
    {
    //send email message to applicant
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(approved[0],Email);
    mail.setReplyTo.(applicant[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}

//if stage 6 and credit denied  
if (credit_line_request_Amount_c()!>=200,000 && <300,000) && (credit_analysis_c = 'deny';)
    {
    //send email message to director
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(Credit Application Declined[0],Email);
    mail.setReplyTo.(director[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}
//if stage 5 and credit approved
if (credit_line_request_Amount_c()!>=200,000 && <300,000) && (credit_analysis_c = 'approved';)
    {
    //send email message to applicant
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(approved [0],Email);
    mail.setReplyTo.(applicant[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}

 

 

Hello,

 

I have an Visualforce page I created that uses an Apex class to query date/time fields from an Account page. In order to filter out unwanted queries I created a custom field (customer_credit_name_c). Now I have two name fields on the Account page and it is confusing. Is there a way to set up a custom formula or rule to auto populate the custom field from the standard name field? I want to be able to hide the custom field. I can include the Apex class and VF page if needed.

 

Thanks

 

Hello, I have a controller creditProcess2 I created for a three column data table for date/time stamped custom fields. The controller has compiled in the sandbox and I am creating the test controller. Here is my code for the test controller:

public class thecreditProcess2Test{
    public static testMethod void testcreditProcess2 () {
    pageReference PageRef = Page.success;
    Test.setcurrentPage(PageRef);
  	creditProcess2 controller = new creditProcess2();
    String nextPage=save.creditProcess2().get.URL(); 
    
     //no parameters and page will fail 
    System.assertEquals ('/apex/failure?error = noParam., nextPage');
    ApexPages.currentPage().get.Parameters().put('qp', 'yyyy'); 
    //enter in test values for the System.Assert 
        creditProcess2 = new creditProcess2();
        creditProcess2.setLastName('lastname');
        creditProcess2.setFirstName('firstname');
        creditProcess2.setCompany('acme');
        creditProcess2.setEmail('firstlast@acme.com');
        nextPage = creditProcess2.save().getUrl();
    //success for new page parameters
    System.assertEquals('/apex/success', nextPage);
    //query for test values
    Lead[] leads = [select id, email from lead where Company = 'acme'];
    System.assertEquals('firstlast@acme.com', leads[0].email);
   }
    }

 

When I compile it I get:

 

Compile Error: Invalid type: thecreditProcess2 at line 5 column 44 

 

Line 5 is the following: creditProcess2 controller = new creditProcess2();

 

I have tried other values for the controller name but nothing seems to be getting past the compile error. Any suggestions? I can include the original controller if needed.

 

Thanks,

Hello, I have a lead zip code search Apex Controller and Visualforce page that I have been working on intermittently. I have posted other questions on this in the past, and have been able to refine the search as only numbers. However, it still gives random values for the number searches. I logged a case and they said to use a LIKE command with OR and include each searchable value. I have tried this but keep getting “unexpected token” errors when I compile.

Everything else is now working but I can’t seem to get it to do a wildcard search or to give exact values when they are entered for the search. Here is the controller. I left the LIKE '985%%'  in there because it will match this exact value but without it I get random values.

public class zipController {
    public String searchResults { get; set; }
    public String displayResults { get; set; }

    String searchText;
    List<Lead> results;
    public String getSearchText() {
        return searchText;
    }

//get results of query
    public List<Lead> getResults() {
        return results;
    }
    public PageReference doSearch() {
    
//query and messages for results or no results
    results = [SELECT Company, Name, Email, PostalCode FROM Lead WHERE PostalCode LIKE '985%%' LIMIT 1000];			                                                                              
    apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, searchText )); 
     if (results.size() == 0) {apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 
     'Sorry,no results for your current zip code search. Make sure you are using the proper format (99999)'));  
      }
     else         
      apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Here is your zip code search results')); 
      
      return null;
    }
}

Here is the Visual Force page:

<apex:page controller="zipController">
    <apex:form >
     <apex:pageMessages />
        <apex:pageBlock mode="edit" id="block">
        <apex:pageBlockSection >
        <apex:pageBlockSectionItem >
    <apex:outputLabel for="searchText"> Enter zip code,5 digits, all numbers</apex:outputLabel>
        <apex:panelGroup >

    <apex:inputText id="searchText" value="{!searchText}" onchange="return validateText(this.value);" />
    <apex:commandButton action="{!doSearch}" value="Search" id="commandbutton"onkeypress="13"/>
        <script> 
            function validateText(numb){ 
            if(isNaN(parseInt(numb))) {alert("Zip code must be entered in numbers only")  
            return false } 
            else  return true };
        </script>   
        </apex:panelGroup>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>

     <apex:actionStatus id="status" startText="requesting..."/>
     <apex:pageBlockSection title="Lead Zip Code Search" id="results" columns="1">
            <apex:pageBlockTable value="{!results}" var="l"
                rendered="{!NOT(ISNULL(results))}">
                    <apex:column value="{!l.postalcode}"/>
                    <apex:column value="{!l.company}"/>
                    <apex:column value="{!l.name}"/>
                    <apex:column value="{!l.email}"/>
            </apex:pageBlockTable>
         </apex:pageBlockSection>
           </apex:pageBlock>
       </apex:form>
</apex:page>

 Thanks

Hello,

 

I have a visual force page and apex controller I have been building to use for lead zip code searches. I was able to get the basic search to work but wanted to validate the input to verfiy they were only 5 digits. I have tried linking to my zip code validation rule but was having some difficulty with that. I have also tried setting up a pattern and matcher class in the controller, but could not get it to recognize a wild card search. Now I am working on a javascript validation. Here is my basic code to test the input and verfiy that it is a number:

       <script> var postalcode = '{!$Component.postalcode}' </script> 
        <script type="text/javascript"> 
        function validateText(numb){ 
            if(isNaN(parseInt(numb))) {alert("zip code is numbers only")  
            return false } 
            else  return true };
        </script>
        

 Here is the entire page including my Ajax/soap for the javascript&colon;

<apex:page controller="zipController">
<script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
    <apex:form >
     <apex:pageMessages />
        <apex:pageBlock mode="edit" id="block">
        <apex:pageBlockSection >
        <apex:pageBlockSectionItem >
    <apex:outputLabel for="searchText"> Enter zip code</apex:outputLabel>
        <apex:panelGroup >
        <apex:inputText id="searchText" value="{!searchText}"/>
        <apex:commandButton value="Go!" action="{!doSearch}"/>
        </apex:panelGroup>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:actionStatus id="status" startText="requesting..."/>
            <apex:pageBlockSection title="Lead Zip Code Search " id="results" columns="1">
            <apex:pageBlockTable value="{!results}" var="l"
                rendered="{!NOT(ISNULL(results))}">
                    <apex:column value="{!l.postalcode}"/>
                    <apex:column value="{!l.company}"/>
                    <apex:column value="{!l.name}"/>
                    <apex:column value="{!l.email}"/>
            </apex:pageBlockTable>
         </apex:pageBlockSection>
           </apex:pageBlock>
       </apex:form>
       
       <script> var postalcode = '{!$Component.postalcode}' </script> 
        <script type="text/javascript"> 
        function validateText(numb){ 
            if(isNaN(parseInt(numb))) {alert("zip code is numbers only")  
            return false } 
            else  return true };
        </script>
        
</apex:page>

I have inserted the javascript at various points on the page, just to see if it would test after or before the search but neither worked.  I have tried numerous approaches to solve the wildcard search and number validation issue, but have not had any luck. I have posted a previous message using a different approach with the controller. Any advice would be appreciated.

Thanks,

I am working on an Apex class and visual force page that will search lead zip codes and provide the company, zip code, contact name, and e-mail when the search is complete. I based it on a class and page I found in the force.com community. I was able to get the class and page working correctly, but there are a couple of modifications I tried to make.

The first was to give a message when there were no search results.  The second was to give an error message when the zip code is entered incorrectly. I based this one on the zip code format validation rule. Here is the Apex class, with my attempt to insert a “no results” message. I tried using a “get,set” with an “if message:

 

public class zipController {
    public String searchResults { get; set; }
    public String displayResults { get; set; }
    String searchText;
    List<Lead> results;
    public String getSearchText() {
        return searchText;
    }
    public void setSearchText(String s) {
        searchText = s;
    }
    public List<Lead> getResults() {
        return results;
    }
public PageReference doSearch() {
    results = (List<Lead>)[FIND :searchText RETURNING Lead(Company, Name, Email, PostalCode)][0];
    apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, searchText)); 
 
          if (results.size() == 0) {
            apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Sorry, no results for current selected criteria'));  
          }
          else
          {
            apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Here are your search results'));

          }

    return null;
    }
}

 

 

I know I am using a numerical value for a string [if (results.size() == 0)] but I am not getting an error when I compile.

 

 

Here is my visual force page:

<apex:page controller="zipController">
    <apex:form >
        <apex:pageBlock mode="edit" id="block">
        <apex:pageBlockSection >
        <apex:pageBlockSectionItem >
    <apex:outputLabel for="searchText"> Enter zip code</apex:outputLabel>
        <apex:panelGroup >
        <apex:inputText id="searchText" value="{!searchText}"/>
        <apex:commandButton value="Go!" action="{!doSearch}"
            rerender="block" status="status"/>
        </apex:panelGroup>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:actionStatus id="status" startText="requesting..."/>
            <apex:pageBlockSection title="Lead Zip Code Search "   	     	id="results" columns="1">
            <apex:pageBlockTable value="{!results}" var="l"
                rendered="{!NOT(ISNULL(results))}">
                    <apex:column value="{!l.postalcode}"/>
                    <apex:column value="{!l.company}"/>
                    <apex:column value="{!l.name}"/>
                    <apex:column value="{!l.email}"/>
            </apex:pageBlockTable>
         </apex:pageBlockSection>
           </apex:pageBlock>
       </apex:form>
</apex:page>

 

On the visual force page, I also tried a “reRendered” command in two different methods. I put these right after the rendered="{!NOT(ISNULL(results))}">

<apex:outputPanel layout="block" rendered="{!AND(displayResults, searchResults.size=0)}">Sorry, your search returned no results.</apex:outputPanel>                       

                    

reRendered="{!NOT(ISNULL(results))}">

            if"{!results}" var="l"

            rendered="{ISNULL(results)}"

            <apex:Message>"Search Returned No Results"</apex:Message>

For the zip code error, here is the validation rule:

AND(

OR(BillingCountry = "USA", BillingCountry = "US"),

NOT(REGEX( BillingPostalCode , "\\d{5}(-\\d{4})?"))

)

 

Error Message: Zip code must be in 99999 or 99999-9999 format.

Error Location: Billing Zip/Postal Code

 

Here is the insert for the visual force page:

<font color="red"><apex:messages styleClass="error" /> </font>

I know I am missing something on this. I also thought about using a “try-throw” with an “if”:

try (

integer i;

            if {(i>5) OR (i<5)} throw new MyException();

            { catch (MyException e)} “error message”

 I would need to set the lead.PostCode string as an integer first NUM(lead.PostalCode)

 

I would appreciate it if someone could take a look and see what I am doing wrong on both of these. For the “no results” in the Apex class I am not getting any errors when I compile, but it does not do anything. For the “incorrect zip code” I cant figure out how to insert the validation rule or possibly how to create it on the page.

 

Thanks,

Hello,

I am modifying a trigger I found in the developer community for checking duplicate leads. Here is the trigger that I downloaded and modified:

 

//This Trigger fires on the Lead object and checks for duplicate e-mail
// zip code and phone number fields
Trigger leadDupCheck on Lead(before insert, before update)

{
//Check to be sure zip and e-mail fields aren't empty
if (Trigger.new.Email !=null&& Trigger.new.PostalCode !=null&& Trigger.new.Phone !=null ){

//This is the query for duplicate e-mail and zip code fields

Lead[]dup = [select id from Lead WHERE Email = :Trigger.new.Email AND PostalCode = :Trigger.new.PostalCode AND Phone = :Trigger.new.Phone ];

// If there is a duplicate then an error message is displayed
// If there is no duplicate information, the program keeps going

    if ( dup.size() > 0 ) {Trigger.new.[Email].addError('This is a   duplicate Lead, do not re-enter');
	}
	else
	{
	 }
      }
}

 I compiled it and received the following error:

Compile Error: Initial term of field expression must be a concrete SObject:LIST:SOBJECT:Lead at line 9 column 49

Which is based on:

 

 

Lead[]dup = [select id from Lead WHERE Email = :Trigger.new.Email

 

 So then I tried to set up an sObject for the Lead:

 

Lead a = new Lead();
SObject s = [select id from Lead WHERE Email = :Trigger.new.Email AND PostalCode = :Trigger.new.PostalCode AND Phone = :Trigger.new.Phone ];

 

 

And received the following error:

Compile Error: Initial term of field expression must be a concrete SObject: LIST:SOBJECT:Lead

 

I was reading some other posts and noticed that trigger.new is used for arrays and that I should use a loop through records. I was also wondering about the “Lead []dup” for the duplicate leads if I had that set up correctly.

Thanks,

i have web to lead page that includes some javascript code used to validate email addresses and verify all fields are filled out. the page routes to a record type but when the javascript validation is included it blocks the routing. 

here is the HTML that includes the javascript that references the validation code:

<form name="information" action= "https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" onsubmit="return validateForm();” >
 

when i take out 'onsubmit="return validateForm();” ' the information is routed to the correct record type but it wont validate the email or that the fields are filled out. the javascript code is accessed by this command.

 

here is the javascript code:

<script>
function validateForm()
{
var x=document.forms["information"]["first_name"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
var x=document.forms["information"]["last_name"].value;
if (x==null || x=="")
{
alert("Last name must be filled out");
return false;
}
var x=document.forms["information"]["email"].value;
if (x==null || x=="")
{
alert("Email must be filled out");
return false;
}
var x=document.forms["information"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
var x=document.forms["information"]["confirm_email"].value;
if (x==null || x=="")
{
alert("Confirm email must be filled out");
return false;
}
var x=document.forms["information"]["email"].value;
var pass= document.getElementById("email").value
var confPass = document.getElementById("confirm_email").value
if(pass != confPass) {
alert('Email fields do not match');
return false;
}
var x=document.forms["information"]["company"].value;
if (x==null || x=="")
{
alert("Company must be filled out");
return false;
}
var x=document.forms["information"]["state"].value;
if (x==null || x=="")
{
alert("State/Province must be filled out");
return false;
}
}

</script>

 

 

Hello,

 

I am working on an idea for a trigger and thought I would post this to the community before I get too far and realize it is not a worthwhile pursuit. Any feedback would be appreciated.

I am proposing a trigger that fires on a custom field to query email and two other custom fields “credit_line_request_Amount_c” and “credit_analysis_c” from Opportunity.

There are different stages to the trigger depending on the dollar amount in “credit_line_request_Amount_c” and if the potential customer was denied or approved per “credit_analysis_c”. Depending on the stage and status an email message will be sent out to the proper user.

I can say my first problem is that I am trying to query the email field from Opportunity. I am trying to talk the credit people into querying from Lead.

Here is my code so far, please excuse some of the pseudo code I have used and any syntax/compile errors, I am still in the planning stages.  

//APEX TRIGGER AND SOQL QUERY TO AUTOMATE PROCESS FROM CREDIT PERSON //DENY/APPROVE AND SEND EMAIL . MUST INCLUDE DATE/TIME OF APPROVE/DENY. 

Trigger denyapprove on Opportunity(after insert, before update){

    //resets trigger after each check
    Set Trigger<> = new Trigger{};
    for (Integer i=0; i<Trigger.new.size();i++) {

     //date time stamp for each check 
    for (credit_line_request_Email_c i : Trigger.new) {
                DateTime now = System.now();         
       
//SOQL Query for data
if(credit_line_request_Amount_c.size()!=0)
    List<Opportunity>=[SELECT credit_line_request_Amount_c, credit_analysis_c, Email    
    FROM Opportunity WHERE Record Type = Credit Approval);

//if stage 2 and credit denied  
if (credit_line_request_Amount_c()!<75,000) && (credit_analysis_c = 'deny';)
//this will need to be picklist field
    {
    //send email message to director
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(Credit Application Declined[0],Email);
    mail.setReplyTo.(director[0],Email);
    Messaging.sendEmail(new Messaging.Email Message[] {mail});
}
//if stage 2 and credit approved
if (credit_line_request_Amount_c()!<75,000) && (credit_analysis_c = 'approved';)
    {
    //send email message to applicant
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(approved[0],Email);
    mail.setReplyTo.(applicant[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}

//if stage 4 and credit denied  
if (credit_line_request_Amount_c()!>=75,000 && <125,000) && (credit_analysis_c = 'deny';)
    {
    //send email message to director
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(Credit Application Declined[0],Email);
    mail.setReplyTo.(director[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}
//if stage 4 and credit approved
if (credit_line_request_Amount_c()!>=75,000 && <125,000) && (credit_analysis_c = 'approved';)
    {
    //send email message to applicant
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(approved[0],Email);
    mail.setReplyTo.(applicant[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}

//if stage 5 and credit denied  
if (credit_line_request_Amount_c()!>=125,000 && <200,000) && (credit_analysis_c = 'deny';)
    {
    //send email message to director
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(Credit Application Declined[0],Email);
    mail.setReplyTo.(director[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}
//if stage 5 and credit approved
if (credit_line_request_Amount_c()!>=125,000 && <200,000) && (credit_analysis_c = 'approved';)
    {
    //send email message to applicant
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(approved[0],Email);
    mail.setReplyTo.(applicant[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}

//if stage 6 and credit denied  
if (credit_line_request_Amount_c()!>=200,000 && <300,000) && (credit_analysis_c = 'deny';)
    {
    //send email message to director
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(Credit Application Declined[0],Email);
    mail.setReplyTo.(director[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}
//if stage 5 and credit approved
if (credit_line_request_Amount_c()!>=200,000 && <300,000) && (credit_analysis_c = 'approved';)
    {
    //send email message to applicant
    Messaging.Email Message mail= new Messaging.Email Message();
    mail.setTemplate.(approved [0],Email);
    mail.setReplyTo.(applicant[0],Email);
}   Messaging.sendEmail(new Messaging.Email Message[] {mail});
}

 

 

Hello,

 

I have an Visualforce page I created that uses an Apex class to query date/time fields from an Account page. In order to filter out unwanted queries I created a custom field (customer_credit_name_c). Now I have two name fields on the Account page and it is confusing. Is there a way to set up a custom formula or rule to auto populate the custom field from the standard name field? I want to be able to hide the custom field. I can include the Apex class and VF page if needed.

 

Thanks

 

Hello, I have a controller creditProcess2 I created for a three column data table for date/time stamped custom fields. The controller has compiled in the sandbox and I am creating the test controller. Here is my code for the test controller:

public class thecreditProcess2Test{
    public static testMethod void testcreditProcess2 () {
    pageReference PageRef = Page.success;
    Test.setcurrentPage(PageRef);
  	creditProcess2 controller = new creditProcess2();
    String nextPage=save.creditProcess2().get.URL(); 
    
     //no parameters and page will fail 
    System.assertEquals ('/apex/failure?error = noParam., nextPage');
    ApexPages.currentPage().get.Parameters().put('qp', 'yyyy'); 
    //enter in test values for the System.Assert 
        creditProcess2 = new creditProcess2();
        creditProcess2.setLastName('lastname');
        creditProcess2.setFirstName('firstname');
        creditProcess2.setCompany('acme');
        creditProcess2.setEmail('firstlast@acme.com');
        nextPage = creditProcess2.save().getUrl();
    //success for new page parameters
    System.assertEquals('/apex/success', nextPage);
    //query for test values
    Lead[] leads = [select id, email from lead where Company = 'acme'];
    System.assertEquals('firstlast@acme.com', leads[0].email);
   }
    }

 

When I compile it I get:

 

Compile Error: Invalid type: thecreditProcess2 at line 5 column 44 

 

Line 5 is the following: creditProcess2 controller = new creditProcess2();

 

I have tried other values for the controller name but nothing seems to be getting past the compile error. Any suggestions? I can include the original controller if needed.

 

Thanks,

Hello, I have a lead zip code search Apex Controller and Visualforce page that I have been working on intermittently. I have posted other questions on this in the past, and have been able to refine the search as only numbers. However, it still gives random values for the number searches. I logged a case and they said to use a LIKE command with OR and include each searchable value. I have tried this but keep getting “unexpected token” errors when I compile.

Everything else is now working but I can’t seem to get it to do a wildcard search or to give exact values when they are entered for the search. Here is the controller. I left the LIKE '985%%'  in there because it will match this exact value but without it I get random values.

public class zipController {
    public String searchResults { get; set; }
    public String displayResults { get; set; }

    String searchText;
    List<Lead> results;
    public String getSearchText() {
        return searchText;
    }

//get results of query
    public List<Lead> getResults() {
        return results;
    }
    public PageReference doSearch() {
    
//query and messages for results or no results
    results = [SELECT Company, Name, Email, PostalCode FROM Lead WHERE PostalCode LIKE '985%%' LIMIT 1000];			                                                                              
    apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, searchText )); 
     if (results.size() == 0) {apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 
     'Sorry,no results for your current zip code search. Make sure you are using the proper format (99999)'));  
      }
     else         
      apexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Here is your zip code search results')); 
      
      return null;
    }
}

Here is the Visual Force page:

<apex:page controller="zipController">
    <apex:form >
     <apex:pageMessages />
        <apex:pageBlock mode="edit" id="block">
        <apex:pageBlockSection >
        <apex:pageBlockSectionItem >
    <apex:outputLabel for="searchText"> Enter zip code,5 digits, all numbers</apex:outputLabel>
        <apex:panelGroup >

    <apex:inputText id="searchText" value="{!searchText}" onchange="return validateText(this.value);" />
    <apex:commandButton action="{!doSearch}" value="Search" id="commandbutton"onkeypress="13"/>
        <script> 
            function validateText(numb){ 
            if(isNaN(parseInt(numb))) {alert("Zip code must be entered in numbers only")  
            return false } 
            else  return true };
        </script>   
        </apex:panelGroup>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>

     <apex:actionStatus id="status" startText="requesting..."/>
     <apex:pageBlockSection title="Lead Zip Code Search" id="results" columns="1">
            <apex:pageBlockTable value="{!results}" var="l"
                rendered="{!NOT(ISNULL(results))}">
                    <apex:column value="{!l.postalcode}"/>
                    <apex:column value="{!l.company}"/>
                    <apex:column value="{!l.name}"/>
                    <apex:column value="{!l.email}"/>
            </apex:pageBlockTable>
         </apex:pageBlockSection>
           </apex:pageBlock>
       </apex:form>
</apex:page>

 Thanks

Hello,

 

I have a visual force page and apex controller I have been building to use for lead zip code searches. I was able to get the basic search to work but wanted to validate the input to verfiy they were only 5 digits. I have tried linking to my zip code validation rule but was having some difficulty with that. I have also tried setting up a pattern and matcher class in the controller, but could not get it to recognize a wild card search. Now I am working on a javascript validation. Here is my basic code to test the input and verfiy that it is a number:

       <script> var postalcode = '{!$Component.postalcode}' </script> 
        <script type="text/javascript"> 
        function validateText(numb){ 
            if(isNaN(parseInt(numb))) {alert("zip code is numbers only")  
            return false } 
            else  return true };
        </script>
        

 Here is the entire page including my Ajax/soap for the javascript&colon;

<apex:page controller="zipController">
<script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
    <apex:form >
     <apex:pageMessages />
        <apex:pageBlock mode="edit" id="block">
        <apex:pageBlockSection >
        <apex:pageBlockSectionItem >
    <apex:outputLabel for="searchText"> Enter zip code</apex:outputLabel>
        <apex:panelGroup >
        <apex:inputText id="searchText" value="{!searchText}"/>
        <apex:commandButton value="Go!" action="{!doSearch}"/>
        </apex:panelGroup>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:actionStatus id="status" startText="requesting..."/>
            <apex:pageBlockSection title="Lead Zip Code Search " id="results" columns="1">
            <apex:pageBlockTable value="{!results}" var="l"
                rendered="{!NOT(ISNULL(results))}">
                    <apex:column value="{!l.postalcode}"/>
                    <apex:column value="{!l.company}"/>
                    <apex:column value="{!l.name}"/>
                    <apex:column value="{!l.email}"/>
            </apex:pageBlockTable>
         </apex:pageBlockSection>
           </apex:pageBlock>
       </apex:form>
       
       <script> var postalcode = '{!$Component.postalcode}' </script> 
        <script type="text/javascript"> 
        function validateText(numb){ 
            if(isNaN(parseInt(numb))) {alert("zip code is numbers only")  
            return false } 
            else  return true };
        </script>
        
</apex:page>

I have inserted the javascript at various points on the page, just to see if it would test after or before the search but neither worked.  I have tried numerous approaches to solve the wildcard search and number validation issue, but have not had any luck. I have posted a previous message using a different approach with the controller. Any advice would be appreciated.

Thanks,

Hello,

I am modifying a trigger I found in the developer community for checking duplicate leads. Here is the trigger that I downloaded and modified:

 

//This Trigger fires on the Lead object and checks for duplicate e-mail
// zip code and phone number fields
Trigger leadDupCheck on Lead(before insert, before update)

{
//Check to be sure zip and e-mail fields aren't empty
if (Trigger.new.Email !=null&& Trigger.new.PostalCode !=null&& Trigger.new.Phone !=null ){

//This is the query for duplicate e-mail and zip code fields

Lead[]dup = [select id from Lead WHERE Email = :Trigger.new.Email AND PostalCode = :Trigger.new.PostalCode AND Phone = :Trigger.new.Phone ];

// If there is a duplicate then an error message is displayed
// If there is no duplicate information, the program keeps going

    if ( dup.size() > 0 ) {Trigger.new.[Email].addError('This is a   duplicate Lead, do not re-enter');
	}
	else
	{
	 }
      }
}

 I compiled it and received the following error:

Compile Error: Initial term of field expression must be a concrete SObject:LIST:SOBJECT:Lead at line 9 column 49

Which is based on:

 

 

Lead[]dup = [select id from Lead WHERE Email = :Trigger.new.Email

 

 So then I tried to set up an sObject for the Lead:

 

Lead a = new Lead();
SObject s = [select id from Lead WHERE Email = :Trigger.new.Email AND PostalCode = :Trigger.new.PostalCode AND Phone = :Trigger.new.Phone ];

 

 

And received the following error:

Compile Error: Initial term of field expression must be a concrete SObject: LIST:SOBJECT:Lead

 

I was reading some other posts and noticed that trigger.new is used for arrays and that I should use a loop through records. I was also wondering about the “Lead []dup” for the duplicate leads if I had that set up correctly.

Thanks,