• XVL
  • NEWBIE
  • 30 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
I have been looking at this forever. Does anyone have any idea what type of Validation Rule to Use? Please point me in the right direction. 
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008zMqIAI





// Copyright (c) 2009, Salesforce.com Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // This trigger requires two custom fields and a validation rule. // trigger ProductScheduleTriggerBulk on OpportunityLineItem (after insert) { // // Get prepped by retrieving the base information needed // Date currentDate; Decimal numberPayments; Decimal paymentAmount; Decimal totalPaid; List<OpportunityLineItemSchedule> newScheduleObjects = new List<OpportunityLineItemSchedule>(); // For every OpportunityLineItem record, add its associated pricebook entry // to a set so there are no duplicates. Set<Id> pbeIds = new Set<Id>(); for (OpportunityLineItem oli : Trigger.new) pbeIds.add(oli.pricebookentryid); // Query the PricebookEntries for their associated info and place the results // in a map. Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>( [select product2.Auto_Schedule_Revenue__c, product2.Num_Payments__c from pricebookentry where id in :pbeIds]); // For every OpportunityLineItem record, add its associated oppty // to a set so there are no duplicates. Set<Id> opptyIds = new Set<Id>(); for (OpportunityLineItem oli : Trigger.new) opptyIds.add(oli.OpportunityId); // Query the Opportunities for their associated info and place the results // in a map. Map<Id, Opportunity> Opptys = new Map<Id, Opportunity>( [select Id, CloseDate from Opportunity where id in :opptyIds]); // Iterate through the changes for (OpportunityLineItem item : trigger.new) { if(entries.get(item.pricebookEntryID).product2.Auto_Schedule_Revenue__c == true) { //OK, we have an item that needs to be Auto Scheduled //Calculate the payment amount paymentAmount = item.TotalPrice; numberPayments = (entries.get(item.pricebookEntryId).product2.Num_Payments__c); paymentAmount = paymentAmount.divide(numberPayments,2); //System.debug('* * * * Base Monthly Amount = ' + paymentAmount); // Determine which date to use as the start date. if (item.ServiceDate == NULL) { currentDate = Opptys.get(item.OpportunityId).CloseDate; } else { currentDate = item.ServiceDate; } totalPaid = 0; // Loop though the payments for (Integer i = 1;i < numberPayments;i++) { OpportunityLineItemSchedule s = new OpportunityLineItemSchedule(); s.Revenue = paymentAmount; s.ScheduleDate = currentDate; s.OpportunityLineItemId = item.id; s.Type = 'Revenue'; newScheduleObjects.add(s); totalPaid = totalPaid + paymentAmount; System.debug('********Date ' + currentDate + ' Amount ' + paymentAmount); currentDate = currentDate.addMonths(1); } //Now Calulate the last payment! paymentAmount = item.TotalPrice - totalPaid; OpportunityLineItemSchedule s = new OpportunityLineItemSchedule(); s.Revenue = paymentAmount; s.ScheduleDate = currentDate; s.OpportunityLineItemId = item.id; s.Type = 'Revenue'; newScheduleObjects.add(s); System.debug('********** LAST PAYMENT **********'); System.debug('********Date ' + currentDate + ' Amount ' + paymentAmount); } // End If Auto_Schedule_Revenue } // End For OpportunityLineItem if (newScheduleObjects.size() > 0) { try { insert(newScheduleObjects); } catch (System.DmlException e) { for (Integer ei = 0; ei < e.getNumDml(); ei++) { System.debug(e.getDmlMessage(ei)); } // // There should be something here to alert the user what failed! // } // End Catch } // End If greater than 0 } // End Trigger ProductScheduleTriggerBulk
 
  • January 06, 2015
  • Like
  • 0
Here is the extenstion for my lead controller?

public class myWeb2LeadExtension {



    private final Lead weblead;



    public myWeb2LeadExtension(ApexPages.StandardController stdController) {

       weblead = (Lead)stdController.getRecord();

    }

    

     public PageReference saveLead() {

       try {
       weblead.whitepaperID__c = Apexpages.currentPage().getParameters().get('cid');

       insert(weblead);

       }

       catch(System.DMLException e) {

           ApexPages.addMessages(e);

           return null;

       }

     PageReference p = Page.ThankYouPageWhitePaper;
     p.getParameters().put('cid', Apexpages.currentPage().getParameters().get('cid'));
 

       p.setRedirect(true);

       return p;
      
    }
   
}
  • October 01, 2014
  • Like
  • 0
Hello, 

I am trying to minimize the amount of sites that I use for a project. The project involves a site with a list of various white papers. The goal is that a link will send an individual to a site form. After submission the form sends one to a "Thank You Page" using  the Web2Lead Extension (and enters the data into Salesforce.  On the "Thank You Page" , there is a direct reference to the whitepaper.  I had to create a page for each. The way I have done this there is 1 site used for each series, but I would like to utilze a more dynamic apex class as the form is the same as is Thank You Page.  Does anyone have any idea how to do this? Below is my code. I have tried using get;set, but they system doesn't let me save. 

Web2Lead Form

<apex:page standardController="Lead" extensions="myWeb2LeadExtension" title="Contact Us" showHeader="false" standardStylesheets="false">

   <apex:define name="body">

   <apex:form >

    <apex:messages id="error" styleClass="errorMsg" layout="table" style="margin-top:1em;"/>

      <apex:pageBlock title="" mode="edit">

        <apex:pageBlockButtons >

           <apex:commandButton value="Save" action="{!saveLead}"/>

        </apex:pageBlockButtons>

        <apex:pageBlockSection title="Contact Us" collapsible="false" columns="1">

         <apex:inputField value="{!Lead.Salutation}"/>

         <apex:inputField value="{!Lead.Title}"/>

         <apex:inputField value="{!Lead.FirstName}"/>

         <apex:inputField value="{!Lead.LastName}"/>

         <apex:inputField value="{!Lead.Email}"/>

         <apex:inputField value="{!Lead.Phone}"/>

         <apex:inputField value="{!Lead.Company}"/>

         <apex:inputField value="{!Lead.Street}"/>

         <apex:inputField value="{!Lead.City}"/>

         <apex:inputField value="{!Lead.State}"/>

         <apex:inputField value="{!Lead.PostalCode}"/>

         <apex:inputField value="{!Lead.Country}"/>

        </apex:pageBlockSection>

     </apex:pageBlock>

   </apex:form>

  </apex:define>


</apex:page>



myWeb2LeadExtension

public class myWeb2LeadExtension {



    private final Lead weblead;



    public myWeb2LeadExtension(ApexPages.StandardController stdController) {

       weblead = (Lead)stdController.getRecord();

    }

    

     public PageReference saveLead() {

       try {

       insert(weblead);

       }

       catch(System.DMLException e) {

           ApexPages.addMessages(e);

           return null;

       }

     PageReference p = Page.ThankYouPageWhitePaper;

       p.setRedirect(true);

       return p;
      
    }
   
}


ThankYouPageWhitePaper



<apex:page showheader="false">
<head>
<link href="//fonts.googleapis.com/css?family=Varela+Round:400" rel="stylesheet" type="text/css"></link>
<title>2 Column CSS Layout - parellel design</title>
<style type='text/css'>
.container{
position: relative;
   left: 0.00%;
   width: 100.00%;
   background-color: #FFFFFFF
}
.header{
   position: relative;
   float: left;
   left: 0.00%;
   width: 100.00%;
   background-color: #FFFFFFF
}
.wrapper{
   left: 0.00%;
   width: 75.00%;
   height: 75.00%;
   background-color: #FFFFFFF
}
.left{
   position: relative;
   float: left;
   left: 0%;
   width: 25.00%;
   background-color: #F0F0F0
}
.right{
   position: relative;
   float: right;
   right: 0.00%;
   width: 75.00%;
   background-color: #FFFFFFF
}
.footer{
   position: relative;
   float: left;
   left: 0.00%;
   width: 100.00%;
   background-color: #FFFFFFF
}
body {
 
   margin:70px 40px 10px 50px;
   font-size: 90%;
   background-color: #FFFFFFF
   float: left;
}

</style>
</head>
<body>
<div class="container">
   <div class="header">
<center>
  <h1> Registration complete</h1>
<p>An email has been sent to you with a link to the document.</p>
<p>You should be redirected within 5 seconds. If you are not, then click the following link:
<a href= "http://sandbox-companywebsite.cs10.force.com/AD/whitepaper"> Click Here</a>
</p>
</center>
</div>
</div>
</body>
</apex:page>

White Paper


<apex:page showheader="false" showChat="false" sidebar="false">
<style>
object {display:block;position:absolute;height:100%;}
</style>
<object data="{!URLFOR($Resource.AACredit)}" type="application/pdf" width="100%" height="auto">

 
</object>
</apex:page>
  • August 19, 2014
  • Like
  • 0
I need to wrtie a trigger to  convert a lead to a contact with a custom object attached to the contact if the lead has field values. For example, if a person signs up for a trial, I need the trial information move to the custom object Trial Information. The fields in the lead section would map to the custom fileds in the custom object. The custom object should only be created if there is a value there. 

Lead Fields: 
First Name- John
Last Name- Smith
Company- ABC Corp
Trial Name- XYZ Mag
Start Date- 4/12/2014
End Date-4/19/2014

Convert Lead to Contact:
Object: Contact
First Name- John
Last Name- Smith
Object/Field: Account (Company)-ABC Corp
Custom Object: Trial Information
Trial Name- XYZ Mag
Start Date- 4/12/2014
End Date-4/19/2014


  • April 10, 2014
  • Like
  • 1
I am trying to create a work flow on a lead that will alert an owner when the lead has been in "Working" status for more than 14 days. At this point, the system should create a task. I have created a date field that tracks the date. I have tried using a formula to count the number of days and set the workflow criteria o 14. That  did not work. I have also tried using a custom field that updates with todays date when the lead is changed to working. But, nothing seemes to work. I know about time based workflows, but I can't "build" on my previous worklow, but doing that prevents the lead from being able to be converted. 
  • April 02, 2014
  • Like
  • 0

I been trying to find out whether there is a way to hide contact's phone number or email from non-owners (viewable by owner and manager)?  If so, how?

  • August 30, 2013
  • Like
  • 0
I need to wrtie a trigger to  convert a lead to a contact with a custom object attached to the contact if the lead has field values. For example, if a person signs up for a trial, I need the trial information move to the custom object Trial Information. The fields in the lead section would map to the custom fileds in the custom object. The custom object should only be created if there is a value there. 

Lead Fields: 
First Name- John
Last Name- Smith
Company- ABC Corp
Trial Name- XYZ Mag
Start Date- 4/12/2014
End Date-4/19/2014

Convert Lead to Contact:
Object: Contact
First Name- John
Last Name- Smith
Object/Field: Account (Company)-ABC Corp
Custom Object: Trial Information
Trial Name- XYZ Mag
Start Date- 4/12/2014
End Date-4/19/2014


  • April 10, 2014
  • Like
  • 1
I have been looking at this forever. Does anyone have any idea what type of Validation Rule to Use? Please point me in the right direction. 
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008zMqIAI





// Copyright (c) 2009, Salesforce.com Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. Neither the name of the salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // This trigger requires two custom fields and a validation rule. // trigger ProductScheduleTriggerBulk on OpportunityLineItem (after insert) { // // Get prepped by retrieving the base information needed // Date currentDate; Decimal numberPayments; Decimal paymentAmount; Decimal totalPaid; List<OpportunityLineItemSchedule> newScheduleObjects = new List<OpportunityLineItemSchedule>(); // For every OpportunityLineItem record, add its associated pricebook entry // to a set so there are no duplicates. Set<Id> pbeIds = new Set<Id>(); for (OpportunityLineItem oli : Trigger.new) pbeIds.add(oli.pricebookentryid); // Query the PricebookEntries for their associated info and place the results // in a map. Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>( [select product2.Auto_Schedule_Revenue__c, product2.Num_Payments__c from pricebookentry where id in :pbeIds]); // For every OpportunityLineItem record, add its associated oppty // to a set so there are no duplicates. Set<Id> opptyIds = new Set<Id>(); for (OpportunityLineItem oli : Trigger.new) opptyIds.add(oli.OpportunityId); // Query the Opportunities for their associated info and place the results // in a map. Map<Id, Opportunity> Opptys = new Map<Id, Opportunity>( [select Id, CloseDate from Opportunity where id in :opptyIds]); // Iterate through the changes for (OpportunityLineItem item : trigger.new) { if(entries.get(item.pricebookEntryID).product2.Auto_Schedule_Revenue__c == true) { //OK, we have an item that needs to be Auto Scheduled //Calculate the payment amount paymentAmount = item.TotalPrice; numberPayments = (entries.get(item.pricebookEntryId).product2.Num_Payments__c); paymentAmount = paymentAmount.divide(numberPayments,2); //System.debug('* * * * Base Monthly Amount = ' + paymentAmount); // Determine which date to use as the start date. if (item.ServiceDate == NULL) { currentDate = Opptys.get(item.OpportunityId).CloseDate; } else { currentDate = item.ServiceDate; } totalPaid = 0; // Loop though the payments for (Integer i = 1;i < numberPayments;i++) { OpportunityLineItemSchedule s = new OpportunityLineItemSchedule(); s.Revenue = paymentAmount; s.ScheduleDate = currentDate; s.OpportunityLineItemId = item.id; s.Type = 'Revenue'; newScheduleObjects.add(s); totalPaid = totalPaid + paymentAmount; System.debug('********Date ' + currentDate + ' Amount ' + paymentAmount); currentDate = currentDate.addMonths(1); } //Now Calulate the last payment! paymentAmount = item.TotalPrice - totalPaid; OpportunityLineItemSchedule s = new OpportunityLineItemSchedule(); s.Revenue = paymentAmount; s.ScheduleDate = currentDate; s.OpportunityLineItemId = item.id; s.Type = 'Revenue'; newScheduleObjects.add(s); System.debug('********** LAST PAYMENT **********'); System.debug('********Date ' + currentDate + ' Amount ' + paymentAmount); } // End If Auto_Schedule_Revenue } // End For OpportunityLineItem if (newScheduleObjects.size() > 0) { try { insert(newScheduleObjects); } catch (System.DmlException e) { for (Integer ei = 0; ei < e.getNumDml(); ei++) { System.debug(e.getDmlMessage(ei)); } // // There should be something here to alert the user what failed! // } // End Catch } // End If greater than 0 } // End Trigger ProductScheduleTriggerBulk
 
  • January 06, 2015
  • Like
  • 0
Here is the extenstion for my lead controller?

public class myWeb2LeadExtension {



    private final Lead weblead;



    public myWeb2LeadExtension(ApexPages.StandardController stdController) {

       weblead = (Lead)stdController.getRecord();

    }

    

     public PageReference saveLead() {

       try {
       weblead.whitepaperID__c = Apexpages.currentPage().getParameters().get('cid');

       insert(weblead);

       }

       catch(System.DMLException e) {

           ApexPages.addMessages(e);

           return null;

       }

     PageReference p = Page.ThankYouPageWhitePaper;
     p.getParameters().put('cid', Apexpages.currentPage().getParameters().get('cid'));
 

       p.setRedirect(true);

       return p;
      
    }
   
}
  • October 01, 2014
  • Like
  • 0
I am trying to create a work flow on a lead that will alert an owner when the lead has been in "Working" status for more than 14 days. At this point, the system should create a task. I have created a date field that tracks the date. I have tried using a formula to count the number of days and set the workflow criteria o 14. That  did not work. I have also tried using a custom field that updates with todays date when the lead is changed to working. But, nothing seemes to work. I know about time based workflows, but I can't "build" on my previous worklow, but doing that prevents the lead from being able to be converted. 
  • April 02, 2014
  • Like
  • 0