• jeremiah_small
  • NEWBIE
  • 5 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hello everyone,

I have a custom object called Stacked Rebate Group (SRG), which is always created from the context of a custom object called Rebate, via the New button on the related list. There are no required fields in SRG. Two lookup fields are populated by the before trigger when the object is saved.

The before trigger automatically duplicates the Rebate two times, and associates the two new copies with the two Lookup relationship for the new Stacked Rebate Group, making a Stacked Rebate Group with three copies of the same Rebate each associated by one of three Lookup fields.

What happens using the default New behavior is the user sees the Edit layout, and the fields that should relate to the two new copies are not filled in yet. Clicking save, without filling in either of the two new records fires the before trigger, and the copies are created, and the Lookup fields are filled in, no problem.

See screen shots below.

The trouble is, I would like to make a simple VF page to override the New behavior, automatically attempting to "click Save" for the user, but I can't seem to get it to work the same way I do with the default behavior, even though I think it should be doing the same thing. Here's the simplest form of what I'm trying in the VF.

Code:
<apex:page standardController="SMART_Stacked_Rebate_Group__c"
action="{!save}">
    <apex:messages />
    <apex:Detail subject="{!SMART_Stacked_Rebate_Group__c.id}"/>
</apex:page>

What happens when I use this page is my trigger show my custom error that says "SRG must be created from and ongoing offer," which only happens if there's no Rebate to duplicate (like if someone were allowed to just click New on the SRG object directly). This seems to point to the fact that the standard controller doesn't get the hand-off in VF the same way that it does when I enable the default New behavior. I've tried removing the Save action and  adding...

Code:
<p>SMART_Stacked_Rebate_Group__c.id: {!SMART_Stacked_Rebate_Group__c.id}</p>

...and it certainly doesn't see the New SRG, but that makes sense until it's been saved. Since it's based on the standard controller, what else would I have to do in my VF to be able to access the handed off Rebate record that is to be duplicated by the trigger.

As I mentioned, the attached pictures show what happens using the default New behavior. First the user is presented with a blank form, excepting the Ongoing Offer Rebate. Then by simply clicking Save, the trigger fills in the other two. I'd like to programmatically click save for them. Can anyone offer any suggestions here?

Jeremiah


Pictures of the default "New" behavior:



Then just click save, and this is where it ends up. I'd like to be able to skip the above step and go directly to the below state on New.


I am trying to call a Visualforce page from a custom list button.  I have done this successfully from a detail page button by creating a page using a standard controller for the detail object, selecting Visualforce page as the content source and then picking the page I wanted from the pull down list for content.
 
However, I can't seem to get this to work for a list button.  I pick the list button option on the custom button or link page, and pick visualforce page for the content source, but I don't get my visualforce page to appear in the content pull down list.
 
Is there something I'm doing wrong?
 
As an adjunct question, should I be using the standard controller for the detail object being displayed at the top of the page or for the objects being referenced in the list (in the case I'm working on now, the objects in the list are the same object as the detail object and reference back to the detail object)? 
 
I understand that one of the benefits of using a visualforce page in this manner is that the id for the detail object is automatically passed to the visualforce page, thereby making data display easier on the detail page.  If a visualforce page can be invoked from a list button, what object id is passed?  That of the detail item at the top of the page?
 
Thanks in advance for your help,
Jeff
 
  • January 16, 2009
  • Like
  • 0
Hello everyone,

I have a custom object called Stacked Rebate Group (SRG), which is always created from the context of a custom object called Rebate, via the New button on the related list. There are no required fields in SRG. Two lookup fields are populated by the before trigger when the object is saved.

The before trigger automatically duplicates the Rebate two times, and associates the two new copies with the two Lookup relationship for the new Stacked Rebate Group, making a Stacked Rebate Group with three copies of the same Rebate each associated by one of three Lookup fields.

What happens using the default New behavior is the user sees the Edit layout, and the fields that should relate to the two new copies are not filled in yet. Clicking save, without filling in either of the two new records fires the before trigger, and the copies are created, and the Lookup fields are filled in, no problem.

See screen shots below.

The trouble is, I would like to make a simple VF page to override the New behavior, automatically attempting to "click Save" for the user, but I can't seem to get it to work the same way I do with the default behavior, even though I think it should be doing the same thing. Here's the simplest form of what I'm trying in the VF.

Code:
<apex:page standardController="SMART_Stacked_Rebate_Group__c"
action="{!save}">
    <apex:messages />
    <apex:Detail subject="{!SMART_Stacked_Rebate_Group__c.id}"/>
</apex:page>

What happens when I use this page is my trigger show my custom error that says "SRG must be created from and ongoing offer," which only happens if there's no Rebate to duplicate (like if someone were allowed to just click New on the SRG object directly). This seems to point to the fact that the standard controller doesn't get the hand-off in VF the same way that it does when I enable the default New behavior. I've tried removing the Save action and  adding...

Code:
<p>SMART_Stacked_Rebate_Group__c.id: {!SMART_Stacked_Rebate_Group__c.id}</p>

...and it certainly doesn't see the New SRG, but that makes sense until it's been saved. Since it's based on the standard controller, what else would I have to do in my VF to be able to access the handed off Rebate record that is to be duplicated by the trigger.

As I mentioned, the attached pictures show what happens using the default New behavior. First the user is presented with a blank form, excepting the Ongoing Offer Rebate. Then by simply clicking Save, the trigger fills in the other two. I'd like to programmatically click save for them. Can anyone offer any suggestions here?

Jeremiah


Pictures of the default "New" behavior:



Then just click save, and this is where it ends up. I'd like to be able to skip the above step and go directly to the below state on New.