2

enter image description hereI want to prepoulate Name field on opportunity with text as "System Generated".

I have written created a VF page

<apex:page standardController="Opportunity" extensions="DefaultOpprtunityNameController" action="{!redirect}"/>

and its controller as

public with sharing class DefaultOpprtunityNameController {

public DefaultOpprtunityNameController(ApexPages.StandardController controller) {

}


public PageReference redirect() {
    PageReference pr = new PageReference('/006/e');
    Map<String, String> m = pr.getParameters();
    // Keep existing parameters
    m.putAll(ApexPages.currentPage().getParameters());
    // Add Opportunity name parameter
    m.put('opp3', '<System Generated>');
    m.put('opp11', 'Requested Info');
    m.put('opp12', '25');
    // Turn off the override so you go to the default UI page (and not an infinite loop)
    m.put('nooverride', '1');
    return pr;
}

}

And overrided standerd Opportunity "New" button with the above VF page

But I am getting an error

Error: Invalid Data.
Review all error messages below to correct your data. The page you submitted was invalid for your session. Please click Save again to confirm your change.

  • Are you getting the error when you click the "New" button or when you click the "Save" button after clicking "New"? – BarCotter Sep 11 '15 at 10:25
  • I am getting error on click of new button on opportunity tab landing page. – Swapnil Kale Sep 11 '15 at 10:33
  • Wondering if it has to do with setting the probability to a string value. – Jenny B Sep 11 '15 at 11:30
2

The problem appears to be with grabbing the parameters from the page where the "New" button is clicked. Try eliminating this line and that should eliminate the error.

m.putAll(ApexPages.currentPage().getParameters());
  • 3
    That what I was seeing as well. I got the error to go away by removing the save_new parameter. – martin Sep 11 '15 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.