• labau
  • NEWBIE
  • 5 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 9
    Replies

Hello All:

 

I work for Rebuild Resources, a small nonprofit in St. Paul, MN. We have been using salesforce.com for a couple of years, and are just starting to push the limits by using VisualForce. I have been trying to learn VF and Apex, and have been able to cobble together what will be a very useful (even if simple) VF page and Controller - it allows a public guest to create a new Lead record and attach a file, save the record, and get redirected to a "Thank You" page.

 

However, while I have been able to piece together the necessary code and make it work in our sandbox, I am completely lost when it comes to testing. I have read over the documentation several times and it is just not clicking. I was hoping an experienced dev here might be able to help us out. It uses only standard objects, so it should be pretty easy to replicate. The code is below:

 

 

public class SaveRedirect {

public Blob artfile {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}

Lead lead;
public Lead getLead() {
if(lead == null) lead = new Lead();
return lead;
}
public PageReference save() {
// Add the lead to the database.
insert lead;

if (resume != null) {
Attachment attach = new Attachment();
attach.Body = artfile;
attach.Name = fileName;
attach.ContentType = contentType;
attach.ParentId = lead.id;
try {
insert(attach);
} catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
}

// Send the user to a custom VF Thank You page on save.
PageReference acctPage = page.ThankYou;
acctPage.setRedirect(true);
return acctPage;
}
}

 

<apex:page Controller="SaveRedirect" sidebar="false" showHeader="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1" >
<apex:inputField value="{!Lead.FirstName}" required="true"/>
<apex:inputField value="{!Lead.LastName}"/>
<apex:inputField value="{!Lead.Product_Quantity__c}" required="true"/>
<apex:inputField value="{!Lead.Company}"/>
<apex:inputFile accept="doc, txt, pdf" filename="{!fileName}" contentType="{!contentType}"filesize="1000" size="50" value="{!artfile}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 Your assistance would do a world of good for our organization - you can read more about what we do at rebuildresources.com.

 

Cheers,

 

Josh LaBau
Rebuild Resources, Inc.

 

 

Message Edited by labau on 07-02-2009 02:10 PM
  • July 02, 2009
  • Like
  • 0

Hello All!

 

I've set up a VF page to take inputs from the user, save the information, and return values based on a formula using a partial page refresh.

 

The formula will evaluate and return correctly the first time, but if changes are made to the inputs, the formula does not re-evaluate. See the code below - this seems like it should be pretty basic. Anyone have an idea how to fix it?

 

 

<apex:page standardController="TQuote__c" apiVersion="14.0"> <apex:form > <apex:pageBlock id="in" title="Edit Quote for {!$User.FirstName}"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!quickSave}" rerender="out, in" status="status"/> </apex:pageBlockButtons> <apex:pageBlockSection > <apex:inputField value="{!TQuote__c.ColLoc1__c}"/> <apex:inputField value="{!TQuote__c.ColLoc2__c}"/> <apex:inputField value="{!TQuote__c.ColLoc3__c}"/> <apex:inputField value="{!TQuote__c.Dollar_Value__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <apex:pageBlock id="out" title="Read View"> <apex:actionStatus startText="updating..." id="status"/> <apex:pageBlockSection > <apex:outputField value="{!TQuote__c.name}"/> <apex:outputField value="{!TQuote__c.ColLoc1__c}"/> <apex:outputField value="{!TQuote__c.ColLoc2__c}"/> <apex:outputField value="{!TQuote__c.ColLoc3__c}"/> <apex:outputField value="{!TQuote__c.ScrSet__c}"/> <apex:outputField value="{!TQuote__c.Id}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:page>

 In the above, ScrSetup__c is a formula field that does a simple calculation based on the ColLoc__c fields. I have been trying to reconcile this for days - any help would be greatly appreciated!

 

 

  • June 19, 2009
  • Like
  • 0

Hello All:

 

I am trying to build what I thought would be a fairly simple VF page. I am trying to utilize the !quicksave action to submit form values and render the result of a formula in an outputField. In this example, the sum of the inputField values are multiplied by $40 to give a setup charge:

 

<apex:page standardController="TQuote__c"> <apex:form > <apex:pageBlock title="Hello {!$User.FirstName}!"> You are viewing quote number {!TQuote__c.name}. <p/> <apex:pageblockSection columns="1"> <apex:inputField value="{!TQuote__c.ColLoc1__c}"/> <apex:inputField value="{!TQuote__c.ColLoc2__c}"/> <apex:inputField value="{!TQuote__c.ColLoc3__c}"/> <apex:outputField value="{!TQuote__c.ScrSet__c}"/> </apex:pageblockSection> <apex:commandButton action="{!quicksave}" value="Calculate"/> </apex:pageBlock> </apex:form> </apex:page>

The first time I hit the button it saves and returns the correct formula value. However, if I change the form values and submit it again, the value of the outputField stays the same. It is as if it is saving but not refreshing the new formula field value.

 

I have searched high and low in the forums and documentation with no luck. Could anyone steer me in the right direction?

Thank you so much!

 

 

  • June 17, 2009
  • Like
  • 0

Hello All:

 

I'm trying to create an Opportunity detail page in which users may edit related data without going to a separate page. In this instance, I want them to be able to edit Contact Roles. I have written a VF page that looks like this:

 

 

<apex:page standardController="Opportunity" tabStyle="Opportunity"> <apex:detail /> <apex:form > <apex:pageBlock title="Change Roles" mode="detail"> <apex:pageMessages /> <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!Opportunity.OpportunityContactRoles}" var="OC"> <apex:column > <apex:inputfield value="{!OC.Contact.Firstname}"/> </apex:column> <apex:column > <apex:inputfield value="{!OC.Contact.Lastname}"/> </apex:column> <apex:column > <apex:inputfield value="{!OC.IsPrimary}"/> </apex:column> <apex:column > <apex:inputfield value="{!OC.Role}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 However, when I click "Save," none of the information seems to take. What am I missing?

 

Any help would be appreciated!


Thanks,


Josh

 

 

  • May 27, 2009
  • Like
  • 0
Hello All:

I am trying to create a form that allows a user to create multiple records for an object, and letting the user add/delete form elements dynamically. The default form might include one line of input, with the option of adding more inputs when a button is pressed. Is there any existing functionality in Visualforce to accomplish this, or will this require Javascript?

Thanks so much,

Josh
  • November 21, 2008
  • Like
  • 0

Hello All:

 

I work for Rebuild Resources, a small nonprofit in St. Paul, MN. We have been using salesforce.com for a couple of years, and are just starting to push the limits by using VisualForce. I have been trying to learn VF and Apex, and have been able to cobble together what will be a very useful (even if simple) VF page and Controller - it allows a public guest to create a new Lead record and attach a file, save the record, and get redirected to a "Thank You" page.

 

However, while I have been able to piece together the necessary code and make it work in our sandbox, I am completely lost when it comes to testing. I have read over the documentation several times and it is just not clicking. I was hoping an experienced dev here might be able to help us out. It uses only standard objects, so it should be pretty easy to replicate. The code is below:

 

 

public class SaveRedirect {

public Blob artfile {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}

Lead lead;
public Lead getLead() {
if(lead == null) lead = new Lead();
return lead;
}
public PageReference save() {
// Add the lead to the database.
insert lead;

if (resume != null) {
Attachment attach = new Attachment();
attach.Body = artfile;
attach.Name = fileName;
attach.ContentType = contentType;
attach.ParentId = lead.id;
try {
insert(attach);
} catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
}

// Send the user to a custom VF Thank You page on save.
PageReference acctPage = page.ThankYou;
acctPage.setRedirect(true);
return acctPage;
}
}

 

<apex:page Controller="SaveRedirect" sidebar="false" showHeader="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1" >
<apex:inputField value="{!Lead.FirstName}" required="true"/>
<apex:inputField value="{!Lead.LastName}"/>
<apex:inputField value="{!Lead.Product_Quantity__c}" required="true"/>
<apex:inputField value="{!Lead.Company}"/>
<apex:inputFile accept="doc, txt, pdf" filename="{!fileName}" contentType="{!contentType}"filesize="1000" size="50" value="{!artfile}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 Your assistance would do a world of good for our organization - you can read more about what we do at rebuildresources.com.

 

Cheers,

 

Josh LaBau
Rebuild Resources, Inc.

 

 

Message Edited by labau on 07-02-2009 02:10 PM
  • July 02, 2009
  • Like
  • 0

Hello All!

 

I've set up a VF page to take inputs from the user, save the information, and return values based on a formula using a partial page refresh.

 

The formula will evaluate and return correctly the first time, but if changes are made to the inputs, the formula does not re-evaluate. See the code below - this seems like it should be pretty basic. Anyone have an idea how to fix it?

 

 

<apex:page standardController="TQuote__c" apiVersion="14.0"> <apex:form > <apex:pageBlock id="in" title="Edit Quote for {!$User.FirstName}"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!quickSave}" rerender="out, in" status="status"/> </apex:pageBlockButtons> <apex:pageBlockSection > <apex:inputField value="{!TQuote__c.ColLoc1__c}"/> <apex:inputField value="{!TQuote__c.ColLoc2__c}"/> <apex:inputField value="{!TQuote__c.ColLoc3__c}"/> <apex:inputField value="{!TQuote__c.Dollar_Value__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <apex:pageBlock id="out" title="Read View"> <apex:actionStatus startText="updating..." id="status"/> <apex:pageBlockSection > <apex:outputField value="{!TQuote__c.name}"/> <apex:outputField value="{!TQuote__c.ColLoc1__c}"/> <apex:outputField value="{!TQuote__c.ColLoc2__c}"/> <apex:outputField value="{!TQuote__c.ColLoc3__c}"/> <apex:outputField value="{!TQuote__c.ScrSet__c}"/> <apex:outputField value="{!TQuote__c.Id}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:page>

 In the above, ScrSetup__c is a formula field that does a simple calculation based on the ColLoc__c fields. I have been trying to reconcile this for days - any help would be greatly appreciated!

 

 

  • June 19, 2009
  • Like
  • 0

Hello All:

 

I am trying to build what I thought would be a fairly simple VF page. I am trying to utilize the !quicksave action to submit form values and render the result of a formula in an outputField. In this example, the sum of the inputField values are multiplied by $40 to give a setup charge:

 

<apex:page standardController="TQuote__c"> <apex:form > <apex:pageBlock title="Hello {!$User.FirstName}!"> You are viewing quote number {!TQuote__c.name}. <p/> <apex:pageblockSection columns="1"> <apex:inputField value="{!TQuote__c.ColLoc1__c}"/> <apex:inputField value="{!TQuote__c.ColLoc2__c}"/> <apex:inputField value="{!TQuote__c.ColLoc3__c}"/> <apex:outputField value="{!TQuote__c.ScrSet__c}"/> </apex:pageblockSection> <apex:commandButton action="{!quicksave}" value="Calculate"/> </apex:pageBlock> </apex:form> </apex:page>

The first time I hit the button it saves and returns the correct formula value. However, if I change the form values and submit it again, the value of the outputField stays the same. It is as if it is saving but not refreshing the new formula field value.

 

I have searched high and low in the forums and documentation with no luck. Could anyone steer me in the right direction?

Thank you so much!

 

 

  • June 17, 2009
  • Like
  • 0

Hello All:

 

I'm trying to create an Opportunity detail page in which users may edit related data without going to a separate page. In this instance, I want them to be able to edit Contact Roles. I have written a VF page that looks like this:

 

 

<apex:page standardController="Opportunity" tabStyle="Opportunity"> <apex:detail /> <apex:form > <apex:pageBlock title="Change Roles" mode="detail"> <apex:pageMessages /> <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!Opportunity.OpportunityContactRoles}" var="OC"> <apex:column > <apex:inputfield value="{!OC.Contact.Firstname}"/> </apex:column> <apex:column > <apex:inputfield value="{!OC.Contact.Lastname}"/> </apex:column> <apex:column > <apex:inputfield value="{!OC.IsPrimary}"/> </apex:column> <apex:column > <apex:inputfield value="{!OC.Role}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 However, when I click "Save," none of the information seems to take. What am I missing?

 

Any help would be appreciated!


Thanks,


Josh

 

 

  • May 27, 2009
  • Like
  • 0
I am not very pleased with this rollout of API 12.  This subsequently broke all of our integration applications using Java and the API, all of our Cast Iron orchestrations, and many of our s-controls.

I thought there was supposed to be reverse compatibility?

We are getting Invalid Session ID errors on everything and it is costing us a TON of money to fix these problems.

Is anyone else having these problems throughout the board?  Any suggestions on how to deal with this on a large scale?