• MLamb2005
  • NEWBIE
  • 170 Points
  • Member since 2008

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 28
    Questions
  • 54
    Replies

Wondering if Excel Connector supports Salesforce API 20. I am able to connect it but it doesn't show any objects. I wanted to access new object Quote that was introduced in the last release. Thanks

  • January 06, 2011
  • Like
  • 0

We have Pardot integrated with our Salesforce (Enterprise) org. The integration isn't great. In particular, we have a custom setup in Salesforce to manage the opt-in or opt-out status of Contacts / Leads. It's a drop-down called Communication Status and it's value drives workflow rules that auto-update the fields Email Opt Out and a custom checkbox called Receive Marketing. The problem is that Pardot tries to sync directly with the Email Opt Out field, which my workflows override. So the two systems end up out of sync in terms who has opted out.

 

As a first step, I want to use the Pardot API to bring back the opted out status for a record in Pardot and put it into a field on that record in Salesforce. Trouble is, I need to do issue an HttpRequest to do that, which can't be done from a Trigger. I want the status in Salesforce to be as "real-time" as possible. 

 

I'm looking for guidance in how I should approach building this feature and improving the integration between the two systems. I think my best bet is a scheduled Apex class, but I'm not entirely sure.

I'm writing a trigger to keep a persistent record of every Contact that has every opted out in a custom object called Opt Out Records. That way, even when they are deleted, and then imported again, they'll be marked "Opted Out" if they are in the Opt Out Records table. And any Contact that is marked Opted Out will have their email address written into the Opt Out Records table. We're keeping track of Opt Opts with a custom field called Communication Status.

 

So, what I have below works to an extent. It takes a batch of Contact records, picks up the entire Opt Out Records table (Issue #1), then rolls through looking for matches (Issue #2, related to #1). If a match is found, that Contact's Communication Status value is updated to "Opted Out". If a match isn't found, and the Contact is Opted Out, they are written into the Out Out Records table (stored and batch inserted, technically).

 

Issue #1: Pulling the entire Opt Out Records table doesn't make sense long term.

Issue#2: Neither does iterating in such a slow way through the Opt Out Records list for each incoming Contact. Eats up the governor very quickly.

 

So, my question, how do I more effectively identify which of the incoming Contacts' email addresses are already recorded in the Opt Out Records? I think that will solve both issues.

 

Thanks all. 

 

 

 

trigger manageContactOptOut on Contact (before update, before insert) {

    List<Contact> theContacts = new List<Contact>();
    for(Contact c : Trigger.new){
        theContacts.add(c); 
        theEmails.add(c.Email);
    }
    
    List<Opt_Out_Record__c> optOutList = new List<Opt_Out_Record__c>([SELECT Email__c from Opt_Out_Record__c]);

    Boolean foundOne = false;

    List<Opt_Out_Record__c> newOptOuts = new List<Opt_Out_Record__c>();

    for(Contact myContact : Trigger.new){        
        for(Integer i=0; i < optOutList.size(); i++){
            //We found their email address in the Opt Out Record object
            if(myContact.Email == optOutList[i].Email__c){
                myContact.Communication_Status__c = 'No - Opted-Out';
                foundOne = true;
            }
        }        
    
        //We did NOT find their email address in the Opt Out Record object
        //If the Communication Status = Opted Out, then add it to the tracking object
        if (foundOne == false && myContact.Communication_Status__c == 'No - Opted-Out') {
            Opt_Out_Record__c newOptOut = new Opt_Out_Record__c();
            newOptOut.Email__c = myContact.Email;
         
            newOptOuts.add(newOptOut);
        }
        
        foundOne = false;
    }
    
    try{
        insert newOptOuts;
    }catch (Exception ex) {
        //Oops
    }
}

 

 

I've built a PageBlockTable that allows users to enter multiple records at one time. The table itself is working fine, I can iterate through and grab the values I need without issue. I'm trying to add some dynamic error messaging to the table to let users know which fields/cells need their attention. I'm using outputText for the error messaging, and my hope is to have a dynamic style for each one, and just toggle "display:inline" and "display:none" from the Apex Controller.

 

However, I can't seem to access a paricular pair of outputText fields. My code ends up turning them on or off for an entire column. Any ideas? Thanks!

 

Visualforce page:

 

 

<apex:form id="theForm">
    
    <apex:sectionHeader title="New Lab Project Hours" subtitle="Lab Project Hour Edit"/>
        
    <apex:pageBlock title="Lab Project Hour Quick Entry" mode="edit">
    <apex:pageMessages id="error" />
        <apex:pageblockButtons >
            <apex:commandButton value="Save" style="padding-left:6px;padding-right:6px" action="{!save}" rerender="error,theForm" />
            <apex:commandButton value="Cancel" style="padding-left:6px;padding-right:6px" action="{!cancel}" rerender="error" />
        </apex:pageblockButtons>
        
        <apex:pageblockSection title="Record Information" columns="2">
            <apex:inputField value="{!Lab_Project_Hours__c.Lab_Project_Name__c}" id="LabProjectName"/>
            <apex:inputField value="{!Lab_Project_Hours__c.Lab_Overflow_Resource__c}" id="LabOverflowResource"/>
            <apex:inputField value="{!Lab_Project_Hours__c.Employee_Name__c}" id="EmployeeName"/>
            <apex:inputField value="{!Lab_Project_Hours__c.Hourly_Utilization_Rate__c}" id="HourlyUtilizationRate"/>
        </apex:pageblockSection>
        
        <apex:pageBlockSection columns="1" title="Hours Worked">
        
            <apex:pageBlockTable HeaderClass="centerHeader" style="width:600px;margin-left:15%" value="{!lphs}" var="a" id="hourTable">
                <apex:column headerValue="Date Worked" styleClass="columnStyle" style="width:35%">
                    <apex:inputField value="{!a.TimeDate__c}" styleClass="{!dateFieldError}" /> <br />
                    <apex:outputText value="Error:" styleClass="errorTextBold" style="{!dateError}" />
                    <apex:outputText value=" Invalid number" styleClass="errorTextBold" style="{!dateError}" />
                </apex:column> 
                
                <apex:column headerValue="Type of Hours" styleClass="columnStyle" style="width:25%">
                    <apex:inputField value="{!a.Type_of_Hours__c}" styleClass="{!typeFieldError}" /> <br />               
                    <apex:outputText value="Error:" styleClass="errorTextBold" style="{!typeError}" />
                    <apex:outputText value=" Invalid number" styleClass="errorText" style="{!typeError}" />
                </apex:column>                
                
                <apex:column headerValue="Number of Hours Worked" styleClass="columnStyle" style="width:40%">
                    <apex:inputField value="{!a.Number_of_Hours_Worked__c}" styleClass="{!numFieldError}" /> <br />                    
                    <apex:outputText value="Error:" styleClass="errorTextBold" style="{!numError}" />
                    <apex:outputText value=" Invalid number" styleClass="errorText" style="{!numError}" />
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
            
        <div style="text-align:center;width:600px;margin-left:15%;font-weight:bold">
            <apex:commandLink value="Add Row" action="{!addRow}" rerender="hourTable,error" immediate="true" /> 
                &nbsp;|&nbsp;&nbsp;
            <apex:commandLink value="Remove Row" action="{!removeRow}" rerender="hourTable,error" immediate="true" />
        </div>
            
    </apex:pageBlock>
    </apex:form>

 

Apex Controller (the relevant piece)

 

public class ControllerSetLabProjectHourEmployeeName{

  private final Lab_Project_Hours__c objLabProject;
  public List<Lab_Project_Hours__c> lphs {get; set;}
  public String returnURL {get; set;}
  
  public String dateError {get; set;}
  public String typeError {get; set;}
  public String numError {get; set;}
  public String dateFieldError {get; set;}
  public String typeFieldError {get; set;}
  public String numFieldError {get; set;}

  // Constructor method
  public ControllerSetLabProjectHourEmployeeName(ApexPages.StandardController stdController){    
    this.objLabProject = (Lab_Project_Hours__c) stdController.getRecord();
    
    dateError = 'display:none;';
    typeError = 'display:none;';
    numError = 'display:none;';
    dateFieldError = '';
    typeFieldError = '';
    numFieldError = '';
         
    lphs = new List<Lab_Project_Hours__c>();
    for(Integer i=0; i<5; i++)
       lphs.add(New Lab_Project_Hours__c());
       
    try{
       User currentUser = [Select Id, Employee_Page__c From User Where Id = : UserInfo.getUserId() Limit 1];
       if(currentUser.Employee_Page__c != null){
         List<Employee__c> listEmployee = [Select Id, Name From Employee__c where Id = : currentUser.Employee_Page__c Limit 1];
         if(listEmployee.size() > 0){
            objLabProject.Employee_Name__c = listEmployee.get(0).Id;
         }  
       } 
     }
     catch(Exception ex){
       ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'Something unexpected happened, please contact an Administrator.'));
     }  
               
     Map<String, String> parentURL = ApexPages.currentPage().getParameters();
     returnURL = parentURL.get('retURL'); 
  }
  
  public void save(){
    Integer numOfRows = lphs.size();
    Integer count=0, totalCount=0, i=0, dateBlank=0, typeBlank=0, numBlank=0;
    String incompleteRows = '';
    
    //Make sure that the entire table isn't blank, and report an error if it is
    for(i=0; i<numOfRows; i++)
      if(lphs[i].TimeDate__c == null && lphs[i].Type_of_Hours__c == null && lphs[i].Number_of_Hours_Worked__c == null)
        count++;
    if(count == numOfRows)
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'You must fill out at least one row to submit hours.'));
    
    count=0;
    totalCount=0;
    
    for(i=0; i<numOfRows; i++) {
      if(lphs[i].TimeDate__c == null){
        count++; dateBlank=1;}
      if(lphs[i].Type_of_Hours__c == null){
        count++; typeBlank=1;}
      if(lphs[i].Number_of_Hours_Worked__c == null){
        count++; numBlank=1;}
            
      totalCount = totalCount + count;
      if(count > 0 && count <3){
        incompleteRows = incompleteRows + (i+1) + ' ';
        
        if(dateBlank == 1){
          dateError = 'display:inline;';
          dateFieldError = 'errorField';
        }
        if(typeBlank == 1){
          typeError = 'display:inline;';
          typeFieldError = 'errorField';
        } 
        if(numBlank == 1){
          numError = 'display:inline;';
          numFieldError = 'errorField';
        } 
      }
         
      count=0;
      dateBlank=0;
      typeBlank=0;
      numBlank=0;
    }
      
    if(totalCount == numOfRows)
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'You must fill out at least one row to submit hours.'));

    if(incompleteRows.length() > 0)
      ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'The following rows are incomplete and need to be fixed: ' + incompleteRows));
    
   // PageReference pageRef = new PageReference(returnURL);
   // return pageRef;
  }
}

 

 

 

 

I'm having issues with a Visualforce email template that is hooked up to our Ideas tab.  Each time a new idea is submitted this email goes out.  Problem is, if the Idea comments contain any formatting (i.e. bold, bullets, italics, etc), those things are not expressed correctly in the resulting email.  I end up seeing tags (i.e. <strong>) as well as characters not coming across properly (i.e. ‘&#39’ instead of the apostrophe.

 

Does anyone know how I can make the HTML render correctly?  Or, how about just stripping it down to display as regular text in the email?


Thanks!

We just installed WikiForce (http://sites.force.com/appexchange/listingDetail?listingId=a0N300000016ta1EAA) and it's working pretty well so far.

 

One gripe we've had is the emails.  They lack any sort of detail, and are just plain not helpful.  Even the embedded links are broken (they don't include the server name, just says "null").

 

Does anyone know if it's possible to edit the format of these emails?

Hi all,

 

Right now we have a newsletter sign-up on the homepage of our website, only requires an email address, pretty standard.  Those submissions go into a system outside Salesforce.  We also have a web-to-lead form that serves as our Contact Us form (name, company, email, etc) which goes into Salesforce as a lead.

 

We would like to have the newsletter sign-up go into Salesforce as well.  How might this be done?  Can you force it in as a lead without a name?

 

Thanks!
Matt

Hi all,  I'm hoping you can shed some light on if this is possible.  I'm developing on Sites, and I'm currently doing error reporting via <apex:pageMessages>; all my errors appear at the top of the page.  What I really want is to make each error appear at the associate field.  I know I could make out outputText and pass over the error message text, but I'd really like to use the Salesforce formatting for error messages.  Any ideas?  Code below...

 

Sites Page:

 

<apex:page id="pg" controller="ControllerAccount" action="{!DoLoad}" title="Welcome to Parent Pulse" sidebar="false" showHeader="false" cache="false" standardStyleSheets="true">

<apex:form id="frm">
<c:ParentHeader />
<apex:pageMessages />

<DIV class="makeRED">*</DIV>1. First Name:&nbsp;<apex:inputText value="{!FirstName}" /><br/><br/>

<DIV class="makeRED">*</DIV>2. Last Name:&nbsp;<apex:inputText value="{!LastName}" /><br/><br/>

 

 Controller:

 

if(FirstName == null || FirstName.trim() == ''){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'1. Please enter your first name.'));
}

if(LastName == null || LastName.trim() == ''){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'2. Please enter your last name.'));
}

 

 

 

 

 

Hi all,

 

I can't seem to find anything on how to get started building reports with Visualforce. Can someone point me in the right direction?

 

My issue is that I've got 12 or so picklists on a webpage that people fill out as part of a profile.  The question is "How frequently do you visit these sites?" and each picklist has 5 text options, with one picklist per site.  Each picklist ties back to a field in Salesforce.  So there are 12 fields to contain the responses for this one question.

 

What I'm trying to see is each picklist as a column (or row) on a single chart, so I can show the responses for the entire question set (all 12 picklists) without using 12 charts.


Is this possible without using Visualforce and I'm just missing it?  If not, can anyone point me to a resource for how to get started tackling this problem with Visualforce?

 

Thanks!
Matt

Hi all,

 

I've got some Campaign Member custom fields that I'm trying to update with a VisualForce page.  The page exists to receive a URL, which consists of a Campaign Member ID and a flag to tell me which field to update.

 

I am able to query the Campaign Member table, find the right Campaign Member, but then when it comes to making the actual data update, I keep getting an Authorization Required page and nothing actually updates.

 

The relevant part of my code is below, any ideas?

 

public without sharing class ControllerWebIQUpdate { public string campaignMemberID{get;set;} public string progressType{get;set;} public string textDisplay{get;set;} public string gettextDisplay(){ return textDisplay; } public ControllerWebIQUpdate(){ PageReference pr = System.currentPageReference(); campaignMemberID = System.currentPageReference().getParameters().get('cmid'); progressType = System.currentPageReference().getParameters().get('ft'); if(campaignMemberID == null){ //Error condition, don't have a 'cmid' value, do something textDisplay = 'Didnt get a CMID'; } else{ CampaignMember testCM = new CampaignMember(); List<CampaignMember> listCM = [Select Passed_Screener__c, Completed__c From CampaignMember Where Id = : campaignMemberID]; if(listCM.size() == 1){ textDisplay = 'Found the CM!'; if(progressType == 'screener'){ testCM = listCM.get(0); testCM.Passed_Screener__c = true; update testCM; textDisplay = 'Passed the screener!'; } else if(progressType == 'completed'){ testCM = listCM.get(0); testCM.Completed__c = true; update testCM; textDisplay = 'Finished the survey!'; } else{ textDisplay = 'Something was wrong with the FT parameter'; //Error condition, incorrect 'ft' value, do something } } else{ textDisplay = 'This shouldnt happen, bad news.'; //Error condition, something went wrong with the CampaignMember query } } } }

 

 

Hi all,

 
I'm trying to add the following check to an on-click piece of JavaScript in a button (to restrict access to the button).  My condition in the "IF" isn't working right, anyone see why?

 

if({!User.ProfileId} <> '00e00000006ojvr'){ alert("This feature is currently only available to Administrators."); } else{ ** Do stuff** }

 


 

Can anyone tell me how to access the current user's User fields within the VisualForce email?

 

I've tried:

 

{!user.Phone}

{!currentuser.Phone}

{!from.Phone}

{!sender.Phone}

 

and got nothing.

 

If this isn't possible, how do you make generic email templates?  I've got 15 people all sending emails using the same templates, so unique, user-based templates are out of the question.

 

Thanks!
Matt

I can't seem to find the answer to this anywhere.  I've got a related list with checkboxes for mutli-select, along with a custom button called Do Anything (see the image below).

 

I'm trying to understand how to recognize, in the coding of the button, which checkboxes were checked and which were not.  This seems trivial but I can't find any supporting documentation about this anywhere.

 

Thanks!

Matt

 

 

Does anyone know if you can access the Recent Items list via Apex code in order to grab the ID of the last viewed item?

 

Thanks,
Matt

Hello all,

 

I've got three objects, Lab Projects, Employees, and Lab Project Hours (junction between the previous two).  New Lab Project Hours records are always created from a Lab Project record.  Someone generously wrote the following code for me, which overrides the New button and automatically fills in the Employee value on new Lab Project Hours records.

 

However, since the New button was overwritten, the Lab Project value no longer is populated, as is the case natively.  I'm thinking I need to pass the ID of the current Lab Project record and pass it into my Apex code, but I'm not sure.  Any help would be greatly apprecaited.

 

 

VisualForce page (simply a redirect):

 

<apex:page standardController="Lab_Project_Hours__c" extensions="ControllerSetEmployeeName" action="{!SetEmployeeName}" > </apex:page>

 

 

Apex Code

 

public class ControllerSetEmployeeName{ private final Lab_Project_Hours__c objLabProjectHours; // Constructor method public ControllerSetEmployeeName(ApexPages.StandardController stdController){ this.objLabProjectHours = (Lab_Project_Hours__c) stdController.getRecord(); this.EmployeeName = ''; this.EmployeeId = ''; try{ User currentUser = [Select Id, Employee_Page_ID__c From User Where Id = : UserInfo.getUserId() Limit 1]; if(currentUser.Employee_Page_ID__c != null){ List<Employee__c> listEmployee = [Select Id, Name From Employee__c where Id = : currentUser.Employee_Page_ID__c Limit 1]; if(listEmployee.size() > 0){ this.EmployeeId = listEmployee.get(0).Id; this.EmployeeName = listEmployee.get(0).Name; } } } catch(Exception ex){ system.debug(ex.getMessage()); } } // public property public string EmployeeName{ get; set; } public string EmployeeId{ get; set; } // This method is used to set employee name and redirect to project hours new page public PageReference SetEmployeeName(){ PageReference pageRef = new PageReference('/a02/e?nooverride=1&retURL=/a02&CF00N40000001moi9_lkid=' + this.EmployeeId + '&CF00N40000001moi9=' + this.EmployeeName); // Note: Please change the field ids 'CF00N40000001moi9_lkid' and 'CF00N40000001moi9', while deploying this code to production pageRef.setRedirect(true); return pageRef; } }

 

 

 

 

Hi all,

 

I have three objects, Lab Projects (Master), Employee (Master), and Lab Project Hour (Junction between Lab Projects and Employee).  Lab Project Hours records are always created from a Lab Projects record, so the Edit page always has the Master-Detail field Lab Project Name auto-filled.

 

What I'm looking to do is auto-fill the Master-Detail field Employee Name.  The necessary data is on the current user's User record in the Employee ID field, and I've written the following SQL statement to access it:

 

 

Id employeePageId = [Select Employee_Page__c from User where Id = : UserInfo.getUserId() Limit 1].Employee_Page__c;

 

So what I'm looking to do is build a Visualforce page that overwrite the 'New' button on the related list Lab Project Hours that will:

 

  • Execute the above SQL query to get the necessary record ID
  • Re-direct users to the standard Edit page for Lab Project Hours
  • Populate the Employee record ID (that was found from the SQL query) into the Employee Name field


If anyone can point me to some resources I'd be greatful, this is my first foray into VF.


Thansk!
Matt

 

 

Hi all,

I'm struggling to debug the code shown below.  The setup is that there are three custom objects, Employee, Lab Project, and Lab Project Hours.  Each Lab Project Hours record has two master-detail fields, one to Employee and one to Lab Project.  The LPH records are always created from a Lab Project, so I'm trying to update the Employee field programatically.  Each User object has the Salesforce ID of that user's corresponding Employee record.

The intent of this code is, after the user clicks 'Save' to create a new Lab Project Hour record, to find the current user, get their Employee ID from their User record, then put that ID into the Employee Name master-detail field of this new LPH record.

The problem is that it never actually updates, and always gives an "Error: Invalid Data", because it thinks that I've left the Employee Name field blank.  If I roll this field back to a Lookup field it works just fine, but I need the M/D to get Rollup Summary fields.

Please advise.

Thanks,
Matt

Code:
trigger updateEmployeeOnProjectHour on Lab_Project_Hours__c (before insert) {
    
   Id employeePageId = [select Employee_Page__c 
                    from User 
                    where Id = : UserInfo.getUserId() Limit 1].Employee_Page__c;

   for(Lab_Project_Hours__c lb : Trigger.new) {

         lb.Employee_Name__c = employeePageId;
    }
}

 

Hi all,

I have three objects in play, one master ("Employee", which contains a page per employee) and several details.  The big issue I'm having is working out my record security and visibility.  We use lookups to the Employee object in a variety of places for resource schedule, so the Employee records must be, at minimum, Public Read Only.

We're adding a new feature to track time off requests.  Naturally, the only people who should see John Doe's time off requests are John Doe and their manager.  I cannot for the life of me figure out how to make it where everyone can see see John Doe through lookups, but only John Doe and his/her manager can go in and access the full record for John Doe (and see all the time off requests he/she has submitted).

Is what I'm talking about even possible?

Thanks,
Matt
Hi all,

I started trying to update a Lookup with Apex, and I've successfully done so (thread here: http://community.salesforce.com/sforce/board/message?board.id=apex&thread.id=10227).  The resulting code is as follows:

Code:
trigger updateEmployeeOnProjectHour on Lab_Project_Hours__c (before insert) {
    for(Lab_Project_Hours__c lb : Trigger.new) {

         String currentUserId = UserInfo.getUserId();
    
         User thisUser = [select thisUser.Employee_Page__c from User thisUser where (thisUser.Id =: currentUserId)];
    
         lb.Employee_Name__c = thisUser.Employee_Page__c;
    }

}

 
Now, I've changed the Lookup to a Master-Detail field and the code no longer works.  It appears that the error checking Salesforce performs on the M-D field happens before the trigger, despite the "before insert" clause.  Additionally, I did have the "before update" clause, but that caused issues for previously created records, so I removed it.

Any guidance would be very helpful...

Thanks!
Matt

Hello all,

I have a process where my users enter project hours as Lab Project Hour records.  For naming purposes, right now I look at the Current User and just user their name as text on the new Lab Project Hour record.  However, I need to modify it where each Lab Project Hour is actually named with a Lookup to my custom Employee object. 

On each Employee object I have a field (Employee Page ID) that contains the unique ID of each user's corresponding Employee page.  So, what I need the Trigger to do is:

 - When each Lab Project Record gets created,
 - Determine the Current User and access their User record
 - Get the Employee Page ID information from the current user's User page
 - Take the Employee Page ID and place it into the Employee field on the new Lab Project Record

What is the best way to accomplish this?  Can you point me in some direction to get started?  I've never written a trigger before, but I'm comfortable coding in several languages, so the learning curve shouldn't be too steep.

Thanks a ton,
Matt
Hey all,
 
Does anyone know if (and how) you can use CSS to center the body of the self-service portal?  I've done everything I can and can't seem to figure out the body.  The header isn't hard, but I can't seem to figure out the rest of it.
 
Thanks!
Matt

Hi,

I am encountering strange problem again. I have a csv file which has around 100 older leads, some of them are 2008,2009 also. When I upload through data loader the leads whose created date is less than 2011 is loaded perfectly, but 2011 leads are not. Those leads have strange created date values like - 11/7/2011 is loaded as 19/4/2011. The time zone setting in data loader, salesforce setup is correctly set.

 

Whats wrong?

We have Pardot integrated with our Salesforce (Enterprise) org. The integration isn't great. In particular, we have a custom setup in Salesforce to manage the opt-in or opt-out status of Contacts / Leads. It's a drop-down called Communication Status and it's value drives workflow rules that auto-update the fields Email Opt Out and a custom checkbox called Receive Marketing. The problem is that Pardot tries to sync directly with the Email Opt Out field, which my workflows override. So the two systems end up out of sync in terms who has opted out.

 

As a first step, I want to use the Pardot API to bring back the opted out status for a record in Pardot and put it into a field on that record in Salesforce. Trouble is, I need to do issue an HttpRequest to do that, which can't be done from a Trigger. I want the status in Salesforce to be as "real-time" as possible. 

 

I'm looking for guidance in how I should approach building this feature and improving the integration between the two systems. I think my best bet is a scheduled Apex class, but I'm not entirely sure.

I am new to SFDC. I am in developer force and when I go to setup->develop->apex classes I don't see a "new" button to create a new apex class. Is there some config setting which i need to turn on for this?

 

I am the platform admin on the sfdc instance.

 

Thanks

What is the syntax to know the Day of the week.

 

And also to subtract one date field with Today's date.

 

the requirement is like this:

 

If(Today=Friday)

{

  if( (account.createdDate - Today) > 21 || (Today - account.CreatedDate) >21 )

  {

    Create case;

  }

}

 

I need the help with the Blue Link part.

  • January 19, 2011
  • Like
  • 0

I am trying to run below given query.I have created a trigger on the  contact object.I have parent to child query.

How do I access the last names associated with each account retrieved by the query.I have stored records which have been retrieved by the below query in the account object.What is the way to access contacts lastnames.Can somebody help.

 

Thanks.

Trick

 

trigger chuma on Contact (after insert) 
{

list<account> t=[SELECT Name, (SELECT LastName FROM Contacts) FROM Account];

System.debug('The total value in the T type variable is'+t);

 

}

  • January 19, 2011
  • Like
  • 0

Is there a way to track email activity inside Salesforce.  I want to be able to see a list of clients that were contacted by email, by my sales staff.  For example:  Sue sent out 10 emails today and here are the clients that she emailed. 

 

Thanks in advance!  If I am posting in the wrong place, my apologies..

 

Stuck again!

 

I am using the following code to produce an error message when the Quantity for specific product numbers (listed below) is up to 499 users AND when the discount exceeds 40%. What I'd like to do is expand this code to include a number of quantity ranges, say 500-999, 1000-1500 etc, where the discount  (against the same product codes) should not exceed 45%, 50%, 60%, respectively.

 

Is there a way to do this in one code string rather than create unique validation rules? Here's what I am using...it works  for up to 499 users, and up to 40% discount:

 

AND(
OR
(Product2.ProductCode= "EN-P-MPS-100",
Product2.ProductCode= "EN-P-PC-100",Product2.ProductCode= "EN-P-CP-100",Product2.ProductCode= "EN-P-IP-100",Product2.ProductCode= "EN-P-AW-100",Product2.ProductCode= "EN-P-AWS-100",Product2.ProductCode= "EN-P-CCE-110",Product2.ProductCode= "EN-P-OC-100",Product2.ProductCode= "GE-P-MPS-100",Product2.ProductCode= "GE-P-PC-100",Product2.ProductCode= "GE-P-OC-100",Product2.ProductCode= "EN-P-ICM-200",Product2.ProductCode= "EN-P-SPPM-200",Product2.ProductCode= "EN-P-MISCA-300",Product2.ProductCode= "EN-P-MIBCA-310",Product2.ProductCode= "EN-P-MISCIT-320"),
AND(
(Quantity<= 499)),  Discount  > 0.40)

 

Put another way, how do I introduce quantity ranges, each with a unique discount % against the same product codes in the same validation rule?

 

Thanks in advance for the help!

Wondering if Excel Connector supports Salesforce API 20. I am able to connect it but it doesn't show any objects. I wanted to access new object Quote that was introduced in the last release. Thanks

  • January 06, 2011
  • Like
  • 0

I'm writing a trigger to keep a persistent record of every Contact that has every opted out in a custom object called Opt Out Records. That way, even when they are deleted, and then imported again, they'll be marked "Opted Out" if they are in the Opt Out Records table. And any Contact that is marked Opted Out will have their email address written into the Opt Out Records table. We're keeping track of Opt Opts with a custom field called Communication Status.

 

So, what I have below works to an extent. It takes a batch of Contact records, picks up the entire Opt Out Records table (Issue #1), then rolls through looking for matches (Issue #2, related to #1). If a match is found, that Contact's Communication Status value is updated to "Opted Out". If a match isn't found, and the Contact is Opted Out, they are written into the Out Out Records table (stored and batch inserted, technically).

 

Issue #1: Pulling the entire Opt Out Records table doesn't make sense long term.

Issue#2: Neither does iterating in such a slow way through the Opt Out Records list for each incoming Contact. Eats up the governor very quickly.

 

So, my question, how do I more effectively identify which of the incoming Contacts' email addresses are already recorded in the Opt Out Records? I think that will solve both issues.

 

Thanks all. 

 

 

 

trigger manageContactOptOut on Contact (before update, before insert) {

    List<Contact> theContacts = new List<Contact>();
    for(Contact c : Trigger.new){
        theContacts.add(c); 
        theEmails.add(c.Email);
    }
    
    List<Opt_Out_Record__c> optOutList = new List<Opt_Out_Record__c>([SELECT Email__c from Opt_Out_Record__c]);

    Boolean foundOne = false;

    List<Opt_Out_Record__c> newOptOuts = new List<Opt_Out_Record__c>();

    for(Contact myContact : Trigger.new){        
        for(Integer i=0; i < optOutList.size(); i++){
            //We found their email address in the Opt Out Record object
            if(myContact.Email == optOutList[i].Email__c){
                myContact.Communication_Status__c = 'No - Opted-Out';
                foundOne = true;
            }
        }        
    
        //We did NOT find their email address in the Opt Out Record object
        //If the Communication Status = Opted Out, then add it to the tracking object
        if (foundOne == false && myContact.Communication_Status__c == 'No - Opted-Out') {
            Opt_Out_Record__c newOptOut = new Opt_Out_Record__c();
            newOptOut.Email__c = myContact.Email;
         
            newOptOuts.add(newOptOut);
        }
        
        foundOne = false;
    }
    
    try{
        insert newOptOuts;
    }catch (Exception ex) {
        //Oops
    }
}

 

 

Can any one tell what is console? and When it is used?

  • December 03, 2010
  • Like
  • 0
  • November 22, 2010
  • Like
  • 0

Hi All

 

I created an excel file and using the SFDC Excel connector, I exported some reports. I refreshed a number of times and then suddenly I keep getting the following error

 

"the internet site reports that the item you requested could not be found. http 1.0 404"

 

can anybody offer any advice?

 

Thanks

 

 

Hello everybody,

 

I have a problem with my code. I have created a new page for the account. I only want to show this page, for certain record types. So I created a redirect page, which redirects the user to either the original page, or the new account page. Below is my code.

 

 

	public PageReference redirectToPage() { 
		System.debug('In redirectToPage from AccountRedirectController');
		PageReference newPage = null; 
 		System.debug('Getting record type parameter:' +ApexPages.currentPage().getParameters().get('RecordType'));
		if(ApexPages.currentPage().getParameters().get('RecordType') == RECORDTYPE_OTHER_ACCOUNT.Id) {
			System.debug('Creating newPage from step with selected record types');
			newPage = Page.NewAccountPage1;
			newPage.getParameters().put('RecordType', RECORDTYPE_OTHER_ACCOUNT..Id);
		} else {
			if(ApexPages.currentPage().getParameters().get('RecordType') != null && ApexPages.currentPage().getParameters().get('RecordType') != RECORDTYPE_TP_ACCOUNT.Id) {
				System.debug('*** information **'+ApexPages.currentPage().getParameters().get('RecordType'));
				newPage = new Pagereference('/001/e?retURL=/001/o&RecordType='+ApexPages.currentPage().getParameters().get('RecordType')+'&ent=Account'); 
				newPage.getParameters().put('nooverride', '1');
			}
		}
		return newPage;
	}

 

 

The problem is with the line

 

ApexPages.currentPage().getParameters().get('RecordType')

 This returns null, when the user only has rights to one specific recordtype. While if the user has rights to multiple recordtypes, and he selects one this line always has a valid ID.

 

Why is the record type not set if the user has only access to one specific record type? And how do I get this specific recordtype in my code, so that I can build a correct redirect?

 

 

Any help would be appreciated, thanks, Jan-Dirk

 

 

Hey friends,

 

Not able to delete feed tracked changes.

My development sandbox is just 10 MB

but due to some programmatic upload of Contacts and Accounts to the sandbox

back and forth, since the chatter was enabled it has generated around some 42,351 feed tracked changes

where as my contact records count is just 476 and my account records count is also just 172

which has totally occupied only some 1 MB exactly,

where as these 42,351 feed tracked changes have occupied 10.3 MB space.

Sicne my sandbox is only 10 MB size, whenever i try to create even a test record for the custom object that i have created am not able to do this because now the total storage is : 11.6 MB and am getting this error :-

 

Data Storage Limits Exceeded, Additional Data Creation Not Allowed!

Your company currently has exceeded its data storage limits including an extra overflow buffer. Per our terms and conditions, we cannot permit additional data creation within our system until your company first reduces its current data storage. Please contact your company's salesforce.com administrator to resolve this. We apologize for any inconvenience this may cause.

 

Tried all possibilities.

I tried deleting data from all feed related objects through data loader (after exporting).

Also have disabled chatter, waited for some days, enabled it back and deleted feeds. Nothing worked out.

 

Can some body help?

 

Regards

Sathya

 

 

I've built a PageBlockTable that allows users to enter multiple records at one time. The table itself is working fine, I can iterate through and grab the values I need without issue. I'm trying to add some dynamic error messaging to the table to let users know which fields/cells need their attention. I'm using outputText for the error messaging, and my hope is to have a dynamic style for each one, and just toggle "display:inline" and "display:none" from the Apex Controller.

 

However, I can't seem to access a paricular pair of outputText fields. My code ends up turning them on or off for an entire column. Any ideas? Thanks!

 

Visualforce page:

 

 

<apex:form id="theForm">
    
    <apex:sectionHeader title="New Lab Project Hours" subtitle="Lab Project Hour Edit"/>
        
    <apex:pageBlock title="Lab Project Hour Quick Entry" mode="edit">
    <apex:pageMessages id="error" />
        <apex:pageblockButtons >
            <apex:commandButton value="Save" style="padding-left:6px;padding-right:6px" action="{!save}" rerender="error,theForm" />
            <apex:commandButton value="Cancel" style="padding-left:6px;padding-right:6px" action="{!cancel}" rerender="error" />
        </apex:pageblockButtons>
        
        <apex:pageblockSection title="Record Information" columns="2">
            <apex:inputField value="{!Lab_Project_Hours__c.Lab_Project_Name__c}" id="LabProjectName"/>
            <apex:inputField value="{!Lab_Project_Hours__c.Lab_Overflow_Resource__c}" id="LabOverflowResource"/>
            <apex:inputField value="{!Lab_Project_Hours__c.Employee_Name__c}" id="EmployeeName"/>
            <apex:inputField value="{!Lab_Project_Hours__c.Hourly_Utilization_Rate__c}" id="HourlyUtilizationRate"/>
        </apex:pageblockSection>
        
        <apex:pageBlockSection columns="1" title="Hours Worked">
        
            <apex:pageBlockTable HeaderClass="centerHeader" style="width:600px;margin-left:15%" value="{!lphs}" var="a" id="hourTable">
                <apex:column headerValue="Date Worked" styleClass="columnStyle" style="width:35%">
                    <apex:inputField value="{!a.TimeDate__c}" styleClass="{!dateFieldError}" /> <br />
                    <apex:outputText value="Error:" styleClass="errorTextBold" style="{!dateError}" />
                    <apex:outputText value=" Invalid number" styleClass="errorTextBold" style="{!dateError}" />
                </apex:column> 
                
                <apex:column headerValue="Type of Hours" styleClass="columnStyle" style="width:25%">
                    <apex:inputField value="{!a.Type_of_Hours__c}" styleClass="{!typeFieldError}" /> <br />               
                    <apex:outputText value="Error:" styleClass="errorTextBold" style="{!typeError}" />
                    <apex:outputText value=" Invalid number" styleClass="errorText" style="{!typeError}" />
                </apex:column>                
                
                <apex:column headerValue="Number of Hours Worked" styleClass="columnStyle" style="width:40%">
                    <apex:inputField value="{!a.Number_of_Hours_Worked__c}" styleClass="{!numFieldError}" /> <br />                    
                    <apex:outputText value="Error:" styleClass="errorTextBold" style="{!numError}" />
                    <apex:outputText value=" Invalid number" styleClass="errorText" style="{!numError}" />
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
            
        <div style="text-align:center;width:600px;margin-left:15%;font-weight:bold">
            <apex:commandLink value="Add Row" action="{!addRow}" rerender="hourTable,error" immediate="true" /> 
                &nbsp;|&nbsp;&nbsp;
            <apex:commandLink value="Remove Row" action="{!removeRow}" rerender="hourTable,error" immediate="true" />
        </div>
            
    </apex:pageBlock>
    </apex:form>

 

Apex Controller (the relevant piece)

 

public class ControllerSetLabProjectHourEmployeeName{

  private final Lab_Project_Hours__c objLabProject;
  public List<Lab_Project_Hours__c> lphs {get; set;}
  public String returnURL {get; set;}
  
  public String dateError {get; set;}
  public String typeError {get; set;}
  public String numError {get; set;}
  public String dateFieldError {get; set;}
  public String typeFieldError {get; set;}
  public String numFieldError {get; set;}

  // Constructor method
  public ControllerSetLabProjectHourEmployeeName(ApexPages.StandardController stdController){    
    this.objLabProject = (Lab_Project_Hours__c) stdController.getRecord();
    
    dateError = 'display:none;';
    typeError = 'display:none;';
    numError = 'display:none;';
    dateFieldError = '';
    typeFieldError = '';
    numFieldError = '';
         
    lphs = new List<Lab_Project_Hours__c>();
    for(Integer i=0; i<5; i++)
       lphs.add(New Lab_Project_Hours__c());
       
    try{
       User currentUser = [Select Id, Employee_Page__c From User Where Id = : UserInfo.getUserId() Limit 1];
       if(currentUser.Employee_Page__c != null){
         List<Employee__c> listEmployee = [Select Id, Name From Employee__c where Id = : currentUser.Employee_Page__c Limit 1];
         if(listEmployee.size() > 0){
            objLabProject.Employee_Name__c = listEmployee.get(0).Id;
         }  
       } 
     }
     catch(Exception ex){
       ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'Something unexpected happened, please contact an Administrator.'));
     }  
               
     Map<String, String> parentURL = ApexPages.currentPage().getParameters();
     returnURL = parentURL.get('retURL'); 
  }
  
  public void save(){
    Integer numOfRows = lphs.size();
    Integer count=0, totalCount=0, i=0, dateBlank=0, typeBlank=0, numBlank=0;
    String incompleteRows = '';
    
    //Make sure that the entire table isn't blank, and report an error if it is
    for(i=0; i<numOfRows; i++)
      if(lphs[i].TimeDate__c == null && lphs[i].Type_of_Hours__c == null && lphs[i].Number_of_Hours_Worked__c == null)
        count++;
    if(count == numOfRows)
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'You must fill out at least one row to submit hours.'));
    
    count=0;
    totalCount=0;
    
    for(i=0; i<numOfRows; i++) {
      if(lphs[i].TimeDate__c == null){
        count++; dateBlank=1;}
      if(lphs[i].Type_of_Hours__c == null){
        count++; typeBlank=1;}
      if(lphs[i].Number_of_Hours_Worked__c == null){
        count++; numBlank=1;}
            
      totalCount = totalCount + count;
      if(count > 0 && count <3){
        incompleteRows = incompleteRows + (i+1) + ' ';
        
        if(dateBlank == 1){
          dateError = 'display:inline;';
          dateFieldError = 'errorField';
        }
        if(typeBlank == 1){
          typeError = 'display:inline;';
          typeFieldError = 'errorField';
        } 
        if(numBlank == 1){
          numError = 'display:inline;';
          numFieldError = 'errorField';
        } 
      }
         
      count=0;
      dateBlank=0;
      typeBlank=0;
      numBlank=0;
    }
      
    if(totalCount == numOfRows)
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'You must fill out at least one row to submit hours.'));

    if(incompleteRows.length() > 0)
      ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'The following rows are incomplete and need to be fixed: ' + incompleteRows));
    
   // PageReference pageRef = new PageReference(returnURL);
   // return pageRef;
  }
}

 

 

 

 

I need a way to have my report have a duration of '4 month rolling starting with the current month'. In April, I want to see 4/1/10 to 7/31/10. Do you know of any way to achieve this? There is no standard duration that works for me. I tried to use a filter of EOD = This Month and EOD = Next 1 Quarter but that I don’t believe would roll correctly. It looks like it works for March but then in April it would give me April, July, August, and Sept.

Any thoughts?
  • March 24, 2010
  • Like
  • 0

I am using a static resource which is our company's logo in a visualforce email.  I get the image to show up when previewing from the app but not when the email is delivered.  I noticed another post that indicates you may need to construct the url for the image in a different way (like in a controller class).  Any ideas?

 

<apex:image value="{!URLFOR($Resource.ZayoLogo)}"/>

 

 

  • December 14, 2009
  • Like
  • 0