+ Start a Discussion
JeremyBJeremyB 

Few conceptual VF override questions

Other than formulas and a few custom S-Controls, as well as some stuff I've yanked from you superstars on this board, I'm mostly a point-and-click type admin.

 

Few questions, just wondering if it's possible:

 

1) I'll start simple.

 

When I create a quote I have some text fields that I don't need displayed on the page when you "Create New", but want them on the regular layout as well as the Edit layout. Is this pretty easy with an override? Someone have some sample code on how to not include fields? 

 

2) Override Sort Products screen.

 

We often have to list the same product several times (as opposed to changing to Quantity 5, we sometimes actually have to list it 5 times).

 

This makes sorting products difficult because all we can see is the Product Name field -- and in this case, it would all read "Product X" which doesn't help us differentiate.

 

If I could amend the Sort table to include a custom field, or the opp line item description, our problems would be solved. Any ideas? I asked the experts about this at Dreamforce and seemed to have stumped them pretty good.

 

THANKS SFDC!

Best Answer chosen by Admin (Salesforce Developers) 
sfdc guy.ax723sfdc guy.ax723

Hi Jeremy,

 

Don't appologize for asking questions. That's how we learn this cool stuff.

 

As for your question. In Eclipse there is a folder under src calles layouts. If you are subscribed to layouts, this folder will have layouts for the Objects you select or all your layouts. For quotes there is a Quote-Quote Layout.layout file. The layout file will tell you what fields are on the page and if they are read only. However it does not give you the visual force syntax that you can copy.

 

I have a recomendation for you to look at.

In Spring 11 there is a new feature called field sets. This allows you to define a set of fields to be used in a vf page. The nice part is you can change the fields at any time without changing code. Here is an example of what you would need to do.

 

Lets assume you want to do this on Quotes.

In SFDC go to setup, customize, quotes, field sets and click new.

  1. Give your field set a label,  name and description. Lets call this field set "CreateNewQuoteFieldSet".
  2. Select fields to add to the fields set and move them to the "available in the field set" and "in the field set" columns. the fields in the right most column will be displayed on your vf page.
  3. Save  the field set.
  4. Create a vf page called "CreateNewQuote" and save it.
  5. Set the standard controller to Quote and the Tab Style to Quote.
  6. Add the addition code below

 

Your final page should look like this

 

 

<apex:page standardController="Quote" tabStyle="Quote">
    <apex:form >
        <apex:sectionHeader title="Quote" subtitle="Create New Quote"/>
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/>
            </apex:pageBlockButtons>

            <apex:pageBlock title="Quote Information">
               <apex:pageBlockSection columns="2">

                   <apex:repeat value="{!$ObjectType.Quote.Fieldset.CreateNewQuoteFieldSet}" var="quotefield" >
                       <apex:inputField value="{!Quote[quotefield]}" />
                   </apex:repeat>
              </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

The final step is to override your new button on the Quote Object to point to this new page.

 

This will display all the fields in the fieldset on your page.

Keep in mind you need to have Spring 11 for this to work. Users will be upgraded to Spring 11 On Feb 5th or 11th depending on what server stack you are on.

 

Good Luck

 

 

All Answers

sfdc guy.ax723sfdc guy.ax723

Jeremy,

You could create a VisualForce page for "Create New" and overide the "New" button in the "Standard Buttons and Links" section of your object to point at your new vfPage.

For the other Pages, Edit and View, you can use your standard page layout.

 

As for your second question about Sort Products, I'll have to give that some thought.

 

sfdc guy

JeremyBJeremyB

Yeah because "Sort" is not a button you can override! Forgot to mention that in my original question.

 

Argh, trying to log into force.com ide but it's saying either incorrect user name / pw / token / locked out...  but I have it all in there correctly and tried the various salesforce host sites.

 

Thanks for your support,

JeremyBJeremyB

For the first part, I tried using EasyPage from the appexchange to get me started with the VF and then simply delete the fields I don't want from the code.

 

Unfortunately Easypage doesn't support Quote Layouts (yet?)

 

I also tried using EasyPage to take a few fields off of the Opportunity Layout during Creation, but it lost my Validation Rules and some fields that were on the right side got moved to the left and stuff. I'm not experienced enough to be able to handle those changes myself.

 

Is there any way in the Force.com IDE to show me the Apex code of what my current Quote Layout looks like?

 

sorry for the newb questions :/

sfdc guy.ax723sfdc guy.ax723

Hi Jeremy,

 

Don't appologize for asking questions. That's how we learn this cool stuff.

 

As for your question. In Eclipse there is a folder under src calles layouts. If you are subscribed to layouts, this folder will have layouts for the Objects you select or all your layouts. For quotes there is a Quote-Quote Layout.layout file. The layout file will tell you what fields are on the page and if they are read only. However it does not give you the visual force syntax that you can copy.

 

I have a recomendation for you to look at.

In Spring 11 there is a new feature called field sets. This allows you to define a set of fields to be used in a vf page. The nice part is you can change the fields at any time without changing code. Here is an example of what you would need to do.

 

Lets assume you want to do this on Quotes.

In SFDC go to setup, customize, quotes, field sets and click new.

  1. Give your field set a label,  name and description. Lets call this field set "CreateNewQuoteFieldSet".
  2. Select fields to add to the fields set and move them to the "available in the field set" and "in the field set" columns. the fields in the right most column will be displayed on your vf page.
  3. Save  the field set.
  4. Create a vf page called "CreateNewQuote" and save it.
  5. Set the standard controller to Quote and the Tab Style to Quote.
  6. Add the addition code below

 

Your final page should look like this

 

 

<apex:page standardController="Quote" tabStyle="Quote">
    <apex:form >
        <apex:sectionHeader title="Quote" subtitle="Create New Quote"/>
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/>
            </apex:pageBlockButtons>

            <apex:pageBlock title="Quote Information">
               <apex:pageBlockSection columns="2">

                   <apex:repeat value="{!$ObjectType.Quote.Fieldset.CreateNewQuoteFieldSet}" var="quotefield" >
                       <apex:inputField value="{!Quote[quotefield]}" />
                   </apex:repeat>
              </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

The final step is to override your new button on the Quote Object to point to this new page.

 

This will display all the fields in the fieldset on your page.

Keep in mind you need to have Spring 11 for this to work. Users will be upgraded to Spring 11 On Feb 5th or 11th depending on what server stack you are on.

 

Good Luck

 

 

This was selected as the best answer
jbardetjbardet

Thank you!!!

 

I'm in the Feb 11th group. Will wait this one out.

 

Many, many thanks for paving the way for me.

 

Jeremy