+ Start a Discussion
GobbledigookGobbledigook 

Going through VF pages without displaying to the User

Hey all,

 

I'm trying to pass values to a Visualforce Page from another VF page, and when I get to that page, it will automatically assign values of Custom Fields to what is being passed in by System.GetParameters(), and then Automatically call a save, so that the User will only see a pageview, and not the edit functionality. 

 

So to make a bit more simple:

1. User Saves a Record.

2. Parameters get passed into another VF page (by clicking a button) that carries a reference that the first Record needs. 

3. User does some cool stuff on the other page, modifying the reference and sends it back to the first page using a button.

4. Page.edit() opens and automatically dereferences the system.getParameters() and assigns them to values on the page.

5. The system saves the page and goes to Page.view(), firing custom workflow, without any User input.

 

Any ideas?

 

So far this is what I have:

 

 

First Page Controller: 

ublic FirstPage(ApexPages.StandardController stdcontroller) 
    { 
        this.C = (Custom_Object__c)stdController.getRecord(); 
        if(system.CurrentPageReference().getParameters().get('Email') == '1')
        {
            PageReference Test = SaveView();
        }
    }

 

 

So in the controller I look for a field called 'Email' and if it's equal to '1', then call:

 

public PageReference SaveView()
    {
        
        update C;
        PageReference GoBack = new ApexPages.StandardController(C).view();
        GoBack.setRedirect(true);
        return GoBack;
    }

 

 

And on my second page (along with some other data) when I click a button:

 

 

public PageReference SaveAndEmail()
    {
        this.AddCallAttendee();
        Custom_Object__c C = new Custom_Object__c(Id = CA.Call_Report__c);
        PageReference GoBack = new ApexPages.StandardController(C).edit();
        GoBack.getParameters().put('Email','1');
        GoBack.setRedirect(true);
        return GoBack;
    }    
    

 

Since Edit is overridden by the first page, it will keep the values that are saved within the Call Report and pass in EMail = '1'.  When I check the page, it's there, but it doesn't either call SaveView(), or doesn't reference the Email itself.

 

Note: This does Compile and Save, the errors in the code above are the result of my failure to know how to copy and paste.

 

Best Answer chosen by Admin (Salesforce Developers) 
GobbledigookGobbledigook

Actually got it. 

 

It was a simple action = "{!DoThis}" in the apex:page. 

 

D'oh.