• Baird_S
  • NEWBIE
  • 29 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 28
    Replies
After users submit a record via REST, a before trigger sets one of the values (DisplayCritterList).  A workflow then triggers a confirmation email to the user, but the confirmation email doesn't include the value from DisplayCritterList.  Here is an initial write-up of the problem (https://docs.google.com/document/d/1tIm3Up-f0HnkLXiGtqcEIEbDuRhPRSd5rp5nOAPro9k/edit?usp=sharing), which I shared with Salesforce Support (no help so far).

Is there a programming workaround?

Theoretically, the value set by the before trigger should be included in the email.  In the sequence of execution (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm), the before trigger is step 3, the workflow is step 10, and sending an email is the last step.  However, it seems that the email which is sent won't access the value of DisplayCritterList until that is committed to the database (Step 19).  (In fact, even setting the workflow to a time-dependent workflow which fires one hour after the process, the email produced is still missing the DisplayCritterList value.)

Here is a debug log (https://docs.google.com/document/d/1QPVGGG0KGFAr7Rchdr7q_gH7bauaTeHEU5x0cgBe0Rg/edit) of the process, with comments on the right side, showing where these steps occur.

Am I missing something here?

How can I get the value for DisplayCritterList into the auto-reply email?

​Thanks for your help.
We've developed an app to monitor water quality, which will be used by the general public.  We want the app to log in to an organizational Salesforce database and submit its data.  Is there a way that it can log in without user input?

I provide a standardized but unmanaged package to clients who have different workflow needs. The workflows sometimes interfere when I deploy new code. Does it make sense to just turn them off, deploy, and turn them on again? That would mean that after deployment when I turn them back on again, the tests would fail.  Doesn't seem optimal.

 

Example: Some of my clients use validation rules that accept only certain amounts for membership dues. They all have different amounts. On top of it they sometimes change the amounts. When I test code for the online payments module, I insert opportunities with random amounts, but if those amounts aren't the same as the ones the client instance accepts, the test fails. I could modify the test amounts to fit the current validation rule, but later the organization could change the accepted amounts and the test would fail again.

 

I suppose I could put the client membership dues amounts in a custom setting so I could set them via in the test, but then I couldn't use them in workflow rules unless they were heirarchies (which they aren't).

 

Any easy solutions to this?

 

Thanks, Baird

 

If you agree that we should be able to turn off specific workflows and validation rules in apex tests, vote for this idea: https://success.salesforce.com/ideaView?id=08730000000BrpCAAS

 

I am getting java.lang.reflect.InvocationTargetException when I am trying to edit and save an existing Test Class. The same test class, I am able to edit and save in another sandbox of the same Production instance. Any help is appreciated.

I'm trying to deploy a package from one sandbox to another and get a failure message:

 

Cannot deploy InstalledPackage in Package Manifest with any other types!

 

I'm using Eclipse version Helios Service Release 1 along with the Spring 2013 version of Force.com IDE.

 

Any clue what's going on?

 

Thanks.

 

Hello

I hope that someone can help me with my code

first, I have a vf page. In this page, there are sections that supposed to be hidden/shown according to the value of a multi-picklist. The standardController "Client Session Record" is a custome object

 

<apex:page standardController="Client_Session_Record__c">

  <apex:sectionHeader title="New client Session Record"
                      subtitle="{!Client_Session_Record__c.name}"/>
  <apex:form >
    
    <apex:pageBlock title="Client Session Record Edit" id="thePageBlock" mode="edit">
      <apex:pageMessages />
 
          <!--the buttons block  -->
          <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
          </apex:pageBlockButtons>
          <!--end of buttons block -->  

      <apex:actionRegion >
        <!--Section 1 -->   
        <apex:pageBlockSection title="Information" columns="2">
            

                  <apex:inputField value="{!Client_Session_Record__c.name}"/>
                  
                  <apex:pageBlockSection >
                      <apex:pageBlockSectionItem >

                      </apex:pageBlockSectionItem>

                      <!-- empty selectItem-->
                      <apex:pageBlockSectionItem />
                  </apex:pageBlockSection>
                  
                  
                  <apex:inputField value="{!Client_Session_Record__c.Date_of_visit__c}"/>
                  <apex:inputField value="{!Client_Session_Record__c.Advisor__c}"/>              
                  <apex:inputField value="{!Client_Session_Record__c.Client__c}"/>
                  <apex:inputField value="{!Client_Session_Record__c.X2nd_Advisor__c}"/>
                 
                  <!-- the condition -->
                  <apex:pageBlockSectionItem >              
                      <apex:outputLabel value="Session Type"/> 
                      <apex:outputPanel > 
                          <apex:inputField value="{!Client_Session_Record__c.Session_Type__c}">
                               <apex:actionSupport event="onchange"
                                            reRender="Section2, Section4"
                                            immediate="true"
                                            
                                            status="status"/>
                          </apex:inputField>
                          <apex:actionStatus startText="Updating the value..."
                                         id="status"/>
                      </apex:outputPanel> 
                  </apex:pageBlockSectionItem>
                  <!-- end of condition -->
                  <apex:inputField value="{!Client_Session_Record__c.Next_Review_Date__c}"/>
                  <apex:inputField value="{!Client_Session_Record__c.Location__c}"/>
                  
                          
        </apex:pageBlockSection>
        <!--Section 1 -->     
        
      </apex:actionRegion>
      

    <!--Section 2 -->  
          
      <apex:pageBlockSection title="Initial" id="Section2"
            columns="2" collapsible="true"  
            Rendered="{!if(Client_Session_Record__c.Session_Type__c=='Initial Assessment',true,false) }"  > 
                     
                     <apex:inputField value="{!Client_Session_Record__c.Recommended_AT__c}"
                         required="true" />  
                         
      </apex:pageBlockSection> 
       
    <!--Section 2 -->       
       
    </apex:pageBlock>
  </apex:form>
</apex:page>

 My problem is that , it didn't work!

 

I've got a complicated controller/pages package which I've been testing using runas(), in order to make sure that the guest profile has access to all the fields and objects it needs to.  My code:

 

//TRY TESTING THIS FOR THE WATERGRASS WEB PROFILE
Profile p = [SELECT Id FROM Profile WHERE Name='WaterGrass Web Profile']; 
      user u = new User(Alias = 'WGWeb', Email='WGWebUser@testorg.com', 
      EmailEncodingKey='UTF-8', LastName='WGWebUser', LanguageLocaleKey='en_US', 
      LocaleSidKey='en_US', ProfileId = p.Id, 
      TimeZoneSidKey='America/Los_Angeles', UserName='WGWebUser@testorg.com');
      insert u;

      System.runAs(u) {


CODE TO BE TESTED

}

 But in my most recent deployments, I run into this error: Insufficient Access ...: Cannot insert a user of type guest.

 

My questions:

  • Is this a new error type?
  • Is there some easy fix?
  • Does it matter whether I test using runas()?  I'm curious whether you other developers use this.

Thanks for your input,

Baird



I'm designing a sign-in page for events.  When attendees sign in, I'd like the page to acknowledge them with "Bob, thanks for attending."  And then after 2 seconds, I'd like the page to return to the blank signin form for the next attendee.

 

I haven't been able to find anything that allows me to delay execution like this in the documentation so far.  Any ideas?

I'm creating a survey, and want to have respondents answer picklist questions using radio buttons.

 

I can do this using the standard selectradio, selectoptions approach.

 

But this requires me to specify the values of the options anew for every question.  With 40 questions that's a lot of coding, although it can be simplified using maps.  But before I dig into that ...

 

Is there an existing jquery or other pre-made javascript function which takes a salesforce picklist field and transforms it from its standard dropdown format into radio buttons, and includes all the values from the picklist field, without having to program those values into it using selectoptions?

 

Thanks in advance, Baird

This is how I ended up with this issue

 

I am receiving IP Address in a URL.

In APEX controller, using pagereference get I extract the IPAddress from query string.

I am verifying this IP Address and passing it to Server from where request came from.

 

This is working all fine in developer edition, but when I tried to test the same in Sandbox using a URL, system threw a error and my page kept on reloading. Any help on this is appreciated.

 

Cyclical server-side forwards detected:

 

Cyclical server-side forwards detected: /apex/validateip?checkip=123.4.56.78&core.apexpages.devmode.url=1

 

 

I imagine this is pretty basic, but I haven't seen any code posted here to calculate the median of a list of numbers.  Here's mine, which could pretty easily be adapted to most uses:

 

List<Integer> testvalues = 
   new List<Integer>();
Double Middle;

testvalues.add(1);
testvalues.add(2);
testvalues.add(3);
//testvalues.add(4);

testvalues.sort();
decimal sizeOfList = testvalues.size();
system.debug('size of list is '+ sizeOfList);
Middle = sizeOfList.divide(2,1);
system.debug('middle of list is ' + Middle);
system.debug('minimum value is ' + testvalues[0]);
system.debug('max value is ' + testvalues[testvalues.size()-1]);
//Calculate median
	if (middle <> middle.round()) {
		system.debug('median is '+ testvalues[middle.intValue()]);
		}
		else {
		decimal lowMedianValue = testvalues[middle.intValue()-1];
		decimal highMedianValue = testvalues[middle.intValue()];
		decimal Median = (lowMedianValue + highMedianValue)/2;
		system.debug('median value is ' + Median);
		}

 I hope that makes someone's day easier.

Baird

Is there a way to insert separate Googlecharts as components into a visualforce page, something like using apex:include, so that I can develop each Googlechart as its separate page?  I've tried using apex:include, but each chart simply renders on top of the last one.

 

Or is it necessary to include the visualization, etc. for each chart in the page header, and then call them separately in the body separated by <div> tags?

 

I hope that's not the only approach ... I'm trying to build a single VF page with ten or so charts embedded, and don't want have a humongous mess in the header.

 

Thanks for your advice,

Baird

Hi,

 

I'm trying to write a class that will autoconvert certain leads to existing opportunities without creating an opportunity, given a lead, a contact Id, an account Id, and an owner Id.

 

I'm using the following code to troubleshoot my problem:

public class autoConvertLead {

	// use this lead as a test
    public PageReference cL() {
		Id id = '00QM0000001LJrl';
		set<Id> idSet = new set<Id>{id};
		
        convertList(idSet);
        return null;
    }


    public void convertList(set<Id> leads) {

LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus 
 where MasterLabel like '%auto%match%' and IsConverted=true limit 1];

        Lead[] leadList = [select Id, account__c, contact__c, contact__r.AccountId,  
        account__r.ownerId from Lead 
                where Id in :leads and isConverted = false];
                    
        for (Lead lead : leadList) {

        system.assert(lead.account__c != null);
        system.assert(lead.contact__c != null);
        system.assert(lead.account__c == lead.contact__r.AccountId);   
                                     
        Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(lead.id);
            lc.setDoNotCreateOpportunity(true); 
          //  lc.setOwnerId(lead.account__r.ownerId);
            lc.setAccountId(lead.account__c);
            lc.setContactId(lead.contact__c);
            lc.setOverwriteLeadSource(false);
			lc.setSendNotificationEmail(false);
    		lc.setConvertedStatus(convertStatus.MasterLabel);

        system.assert(convertStatus.MasterLabel != null);
        system.debug(lc);
                
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        System.assert(lcr.isSuccess());
        }
    }
}

 

 

I'm getting "INVALID_STATUS, invalid convertedStatus: Convert - Auto-match to Existing Contact: []: Class.autoConvertLead.convertList: line 36, column 58".

 

I'm taking all the precautions in my code.  I'm ensuring the status value is valid first before using it.:

LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus 
 where MasterLabel like '%auto%match%' and IsConverted=true limit 1];

 

I'm ensuring the lead has the requisite IDs for everything else.  

 

I'm able to convert a clone of the same lead (same record type too)  through the usual steps in the Salesforce.com UI and converting the lead that way, selecting exactly the same Status and I'm having no problem with that.

 

There isn't very much in the way of postings around this topic.

 

Are there any lead conversion wizards out there??

 

Thanks.

I got this error trying to deploy some test code: 

 

System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>

 

Is anyone familiar with this? 

Is it possible to create a dataTable that contains fields that are not in the sObject of the dataTable. Perhaps a check box or a picklist or both. This question sort of stems from this thread, http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=691 ,  which to be honest I haven't totally understood.

Here is a real use case that we are looking at addressing with Visual Force. We would like to pull a list of contacts and do mass emailing using Apex Email services. Essentially we would pull a list of contacts and put this in a dataTable but on the left side of the dataTable there would check boxes that indicate if we would like to send this user an email. There would also be another column that is a picklist which determines what type email they should receive.  A user would then make their selections and hit the send email button.

Neither of these fields are on the contact as they would only be relevant for this VF page. So is it possible to build something like this where the checkbox and and picklist value are passed to a collection of contacts?

Here is what I have so far. I know its not right as all of the checkboxes and picklist are pointing to the same variable but I think it gives you an idea of what we are trying to do.
Page:
Code:
<apex:page controller="contacts">
        <apex:panelGrid columns="1" id="theGrid" width="50%" >
        <apex:pageBlock>
        <apex:form>
        <apex:dataTable value="{!Contacts}" var="con" styleClass="list">
                <apex:column>
                        <apex:facet name="header"><apex:inputCheckbox/></apex:facet>
                        <apex:inputCheckbox/>
                </apex:column>
                <apex:column>
                        <apex:facet name="header">Name</apex:facet>
                        <apex:outputText value="{!con.Name}"/>
                </apex:column>
                <apex:column>
                        <apex:facet name="header">Phone</apex:facet>
                        <apex:outputText value="{!con.Phone}"/>
                </apex:column>
                <apex:column>
                        <apex:facet name="header">Mailing City</apex:facet>
                        <apex:outputText value="{!con.MailingCity}"/>
                </apex:column>
                <apex:column>
                        <apex:facet name="header">Email</apex:facet>
                        <apex:outputText value="{!con.Email}"/>
                </apex:column>
                <apex:column>
                        <apex:facet name="header">Email Type</apex:facet>
                        <apex:selectList value="{!emailType}" size='1'>
                                <apex:selectOptions value="{!emails}"/>
                        </apex:selectList>
                </apex:column>
        </apex:dataTable>
        </apex:form>
        </apex:pageBlock> 
        </apex:panelGrid>
</apex:page>

Controller:
Code:
public class contacts {
    
        Contact [] Contacts;
        String emailType;
        
        public List<Contact> getContacts(){
                if(contacts == null){
                        contacts = [select Id, Name, Phone, MailingCity, Email from Contact limit 10];
                } 
                return Contacts;
        }

        public void setemailType(String emailType){
                this.emailType= emailType;
        }

        public List<SelectOption> getEmails(){
                List<SelectOption> options = new List<SelectOption>();
                
                options.add(new SelectOption('','-None-'));
                options.add(new SelectOption('Renewal Notice','Renewal Notice'));
                options.add(new SelectOption('White Paper','White Paper'));
                options.add(new SelectOption('Phone Call Follow Up','Phone Call Follow Up'));
                              
                return options;
           
        }

 public String getEmailType() {
        return emailType;
     }
}