• 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.
Recently got this error.

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Contribution Record Type: this ID value isn't valid for the user: 012i0000000E0suAAC: [RecordTypeId]

I checked all the user profile permissions, etc.  Finally discovered that another user had deactivated the Recordtype.  I reactivated it, error is gone.

Hope that saves time for someone else.
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'm working with a programmer on a native Android app.  In the current version, I have to go through a Salesforce login screen in order for the app to transfer its information to the Salesforce database.

Am I right that the app can signin automatically?  If so, can you point me to the instructions to do this?  Or can you give some paid time to guide my programmer to a solution?

If I create an automatic signin, what's the best way to avoid having to change passwords and tokens while still maintaining security?  Create a user with "password never expires" and very limited permissions?

Thanks for your help,
Baird

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

 

Hi folks,

 

I am knocking my head against the wall, trying to get a an outputText field on a visualforce page to describe local time zone, and can't figure out what I'm missing.  There are many helpful emails on the forum but none that give us a checklist.  So, facing this challenge myself, here's what I've done - and maybe you can add what I've missed, so everybody has an easy place to find the answer (and so I figure this out):

 

  1. Set the site guest user's timezone to the local time zone.  Setup / Develop / Sites / click on the site name / Public Access Settings / View Uers / Edit and then under Time Zone pick the correct time zone.
  2. Format the field as follows
    <apex:outputText value="{0,date,MM'/'dd'/'yyyy, HH:mm:ss z}">
                    <apex:param value="{!Opportunity.Fill_Date_Time__c}"/>
    </apex:outputText>

    You can modify the format by modifying the string for the value.

     

    Have I missed a step?

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'd like to play a notification sound when a user clicks the "submit" button on a website-based VF page.

 

Is there a way to do this?

 

I've assumed that it will require javascript, and that the .wav file needs to be stored in static resources, but haven't found any solutions.

 

Has anybody managed to do this yet?

 

Thanks for your guidance,

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

I've created several webforms and multi-page surveys using Visualforce pages.  After creating them I have colleagues test them.  When they go live, the great majority of users have no trouble, but there is a persistent minority that reports things like this:

  •  page locks up (especially when using multi-picklists);
  •  went through entire survey, didn't get acknowledgement email, and when I check, no record of the survey has been created;
  •  multiple acknowledgement emails, only one survey registered.

So far, I've tried:

  • removing multi-picklists; 
  • avoiding the use of i-frames.  This seems to reduce the incidence of problems, but not eliminate it; and
  •  including code to force IE9 into compatibility mode.

Still, some problems continue.

 

Do others have these problems?  Any suggestions for fixes?

 

Any suggestions for how to test for them in order to identify the causes?

 

I am concerned because I can't scale up without having forms that are rock solid.  I always figured that going with the simplest configuration - VF pages without javascript, etc - would yield the most reliable customer experience.

 

Thanks for your suggestions,

Baird

I've created a survey, a series of VF pages accessed through sites.  One page uses a multi-select picklist, and while the great majority of users have no problems, a small percentage of users find that the survey consistently hangs when they try to enter values into the multi-picklist.

 

I've already used the line


      Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');

 

in order to ward off browser compatibility issues with IE9.

 

Is this a known issue, or should I be looking for a problem in my code?  If so, any suggestions as to what the code problem might be?

 

Thanks,

Baird

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

I'm still pretty new at this, and I'm trying to add a PayPal button to my page.  The page gathers basic data - name, address, etc. - and the button should  open a new window onto the PayPal site (so that my website doesn't have any credit card numbers pass through it).  I've got the PayPal button HTML code, but don't know how to translate it on the visualforce page.

 

The PayPal HTML code is:

 

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">  
 
 <!-- Identify business to collect the payments. -->   
 <input type="hidden" name="business"  value="baird_1327341394_biz@leadgreen.org">  
 
<!-- Specify a Donate button. -->  
 <input type="hidden" name="cmd" value="_donations">  
 
 <!-- Specify details about the contribution -->   
 <input type="hidden" name="item_name" value="{!opp.name}">  
 <input type="hidden" name="item_number" value="Fall Cleanup Campaign">  
 <input type="hidden" name="currency_code" value="USD">   
  <input type="hidden" name="amount" value="{!opp.amount">   
 <input type="hidden" name="first_name" value="{!pcontact.firstname}">
 <input type="hidden" name="last_name" value="{!pcontact.lastname}">
 <input type="hidden" name="address1" value="{!pcontact.MailingStreet}">
 <input type="hidden" name="city" value="{!pcontact.MailingCity}">
 <input type="hidden" name="state" value="{!pcontact.MailingState}">
 <input type="hidden" name="zip" value="{!pcontact.MailingPostalCode}">
 <input type="hidden" name="email" value="{!pcontact.email">
 
 <input type="image" name="submit" border="0" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" alt="PayPal - The safer, easier way to pay online">  
 <img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" >  
 
</form>

 I've tried translating into VF, but don't find any equivalent for elements like 'method = "post".'

 

So I'd appreciate your guidance on the approach I should take.

 

Baird

 

I just got off a screen-share with a client, and was able to record some really odd behavior: "Chosen" values in a multi-picklist move back to "Available" on their own.  Then the application freezes.  Debug logs show no error.

 

Here's a link to the movie.  http://www.mediafire.com/?6r67u2tmv37obda 

 

You can skip past the first two-thirds - the odd behavior is in the final third.

 

This is a survey with over 100 respondents, and I've seen this twice so far, but I'll bet it's happened more often.  In both cases, switching from IE to another browser solved the problem.

 

Has anyone else experienced this?  I've submitted a case, and will report back what SF tells me.

 

Baird

I'm a newbie at this, but thought I'd better find out if I could do this in native VF before I start fiddling with javascript.

 

I've created a VF survey that runs inside a Drupal i-frame.  Some of the survey pages are long, and require scrolling to the bottom.  When users click "Next Page," they end up seeing a lot of blank space at the bottom of the iframe, and have to figure out that they should scroll back to the top to the beginning of the next page.  As you VF programmers probably know, not all users figure this out, and the multiple scroll bars confuse them.

 

We've tried javascript for window resizing.  The problem with javascript so far is that it conflicts with the jquery SF uses for things like lookup buttons and multi-picklists, so putting the page resizing javascript on pages with those features breaks the SF functionality.

 

Is there a simple VF way to the "Next Page" button to go to the top of the i-frame?

 

Thanks,

Baird

This ought to be really simple.  But I've beaten my head against it for a while, so humbly request your guidance.

 

I'm creating a VF page to allow users to enter both account and contact data together.  I've stripped it down to the simplest version just to debug it.

 

The user enters the Account.name, Contact.firstname and Contact.lastname and clicks submit.

 

<apex:page Controller="enterAccountContact3" showheader="false">
<apex:form >
<h2>Account</h2><br/>
Account Name <apex:inputfield value="{!acct.name}"/><br/>
<h2>Contact</h2>
First name" <apex:inputfield value="{!ctct.FirstName}" required="true" /><br/>
Last name  <apex:inputfield value="{!ctct.LastName}" required="true" /><br/>

<apex:commandButton action="{!submit}" value="Submit" immediate="true" />
</apex:form>
</apex:page>

When the user clicks "submit," the controller is supposed to insert the acct and then ctct (with ctct.accountid=acct.id).

 

public class enterAccountContact3 {

    public Contact ctct {get; set;}
    public Account acct {get; set;}

    public enterAccountContact3() {
    ctct = new Contact();
    acct = new Account();}

public pageReference submit(){
    system.debug('At the beginning of submit(), acct is '+acct.name+' and contact is '+ctct.firstname+
     ' '+ctct.lastname);
    insert acct;
    Ctct.accountid = acct.id;
    insert ctct;
    PageReference done = Page.enteredAccountContactPage;
    done.setRedirect(false);
    return done;
}

But the insert actually never begins.

 

When submit() is invoked, I get: Attempt to de-reference a null object, and the line number references the acct.name.  I've tried to solve this various ways, with an explicit getter, etc., but am never able to get the values entered on the VF page to be available to the controller.  So even at the beginning of the submit() method, before any other validation rules or anything has been invoked, the acct.name is still null.  

 

What am I missing here?

 

Many thanks in advance for your help,

Baird

First off, thanks to Bob Buzzard and everyone else I've been learning from in these discussion boards.  You've gotten me this far, and with a little more help I think I'll be home.

 

I'm trying to reveal an error message, "That event is already full" when a user tries to sign up for an event that's sold out (slots_remaining < 1).

 

The relevant part of the visualforce code is 5 lines from the bottom, where I'd like the error message to appear below the inputfield for slots_remaining__c.

 

This is the page (public_event_select_page):

<apex:page showheader="false" cache="false" standardController="Campaign" extensions="Public_Event_Controller2">
<apex:stylesheet value="{!$Resource.wg_styles}"/>

        <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/>

            <apex:form >
                <apex:dataTable value="{!campaign}" var="c" cellPadding="10" border="0">
                  <apex:column width="100px" style="vertical-align: top;">
                    <apex:facet name="header">Name</apex:facet>
                    <apex:commandLink action="{!prepsignup}" value="{!c.name}" id="theButton">
                        <apex:param assignTo="{!passCampID}" value="{!c.ID}" name="passCampID"/> 
                        </apex:commandLink> 
                  </apex:column>
                  <apex:column style="vertical-align: top;">
                    <apex:facet name="header">Short description</apex:facet>
                    {!c.description}
                  </apex:column>
                  <apex:column style="vertical-align: top;">
                    <apex:facet name="header">Date and time</apex:facet>
                    <apex:outputfield value="{!c.Event_Time_Shifted__c}"/>
                 
                  </apex:column>
                  <apex:column style="vertical-align: top;">
                    <apex:facet name="header">Cost</apex:facet>
                     <apex:outputText value="{0,number,$#,####.##}">
                        <apex:param value="{!c.Event_Cost__c}" />
                     </apex:outputText>
                    
                  </apex:column>
                  <apex:column style="vertical-align: top;">
                    <apex:facet name="header">Places remaining</apex:facet>
                     <apex:inputfield value="{!c.Slots_remaining__c}" />                  
                  </apex:column>
                </apex:dataTable>
            </apex:form>    
        </apex:page>

 And the relevant part of the controller (public_event_controller):

 

public PageReference prepSignup() {
    system.debug('Beginning prepSignup.  passCampID is now '+ passCampID);
    Camp = [SELECT Id ,Name, Description, Description_Long__c, Event_Cost__c, 
        Event_Location__c, Event_Date_time__c, Waiver_Required__c,
        Event_Time_Shifted__c, Slots_Remaining__c, CnP_URL__c FROM Campaign 
        WHERE id = :passCampID limit 1];
        system.debug('Camp.ID is now ' + Camp.ID);
    if (camp.Slots_remaining__c >= 1) {
        results = null;
        createNewLead = false;
        system.debug('Camp.slots_remaining__c is now '+ camp.slots_remaining__c);
        PageReference signUpForEvent = Page.Public_Event_Signup_Page2;
        signUpForEvent.setRedirect(false);
        return signUpForEvent;}
    else {
        camp.slots_remaining__c.addError('This event is full.'); 
        return null;
        }
} // END PREPSIGNUP()

At present the controller behaves as desired, except that no error message appears.

 

Maybe the problem is that when the controller returns null and visualforcepage rerenders the initial page (public_event_select_page2), the new error message is no longer associated with the campaign.  the campaigns displayed on thep age are selected by

 

public List<Campaign> getCampaign() {
    return [select campaign.name, id, Description, Event_Date_Time__c, Event_Time_Shifted__c, 
    recordtypeid, Event_Cost__c,  Slots_Remaining__c, Waiver_Required__c, CnP_URL__c from Campaign where 
    (Event_Date_Time__c >= Today and (recordtype.name = 'Public Event' 
    or recordtype.name = 'Volunteer Event')) ORDER BY Event_Date_Time__c ASC];
}

 I've tried to follow Bob Buzzard's example but since he's iterating through an object differently, I'm not surely how to get the error message back to the visualforce page.

 

Thanks in advance for your help,

Baird 

From the opportunity object, I'm allowing users to select from a list of thank-you letter templates which are stored as VF pages.  When they click on one of the list, I'd like to render that particular page, so they can print it and save it.

 

I'm able to render the list of VF pages, but can't get the PageReference to redirect to the chosen VF page.  I'm fairly new at this, and maybe there's a much easier way to do it.

 

When users select the thank-you letter format (in a VF Page), then the relevant page coding is:

 

<apex:commandLink action="{!renderLetter}" value="{!tt.Name}">                       

<apex:param name="TemplateName" value="{!tt.Name}"/>                   

</apex:commandLink>

 

This calls the renderLetter method:

 

public PageReference renderLetter() {   

string ChosenTemplate = System.currentPageReference().getParameters().get('TemplateName');   

PageReference renderLetter = Page.ChosenTemplate;

return renderLetter;   

}

 

But of course I simply get the error message that no Page called ChosenTemplae exists.  I haven't been able to find out how to get the Page.ChosenTemplate to recognize that ChosenTemplate is a variable, nor figure out the right way around this.

 

Any answers?  Many thanks in advance for your help.

 

Baird

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'm working with a programmer on a native Android app.  In the current version, I have to go through a Salesforce login screen in order for the app to transfer its information to the Salesforce database.

Am I right that the app can signin automatically?  If so, can you point me to the instructions to do this?  Or can you give some paid time to guide my programmer to a solution?

If I create an automatic signin, what's the best way to avoid having to change passwords and tokens while still maintaining security?  Create a user with "password never expires" and very limited permissions?

Thanks for your help,
Baird
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.

  • November 07, 2013
  • Like
  • 0

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;
     }
}

 


  • March 20, 2008
  • Like
  • 0