You need to sign in to do that
Don't have an account?
Ronaldo Costa
Create ID upon VF page load
I tried to search this over and over, but did not find any previous need like this one.
Is it possible to automatically create an ID upon loading of a visualforce page?
I was thinking about making the <apex:page "action="{!NewID}" > tag.. like the following:
public PageReference NewID() {
Object__c NewID = new Object__c (name = 'New Record');
insert NewID;
String changepage2 = '/apex/MyVF_Page?id='+NewID.Id;
PageReference pageref2 = new Pagereference(changepage2);
pageref2.setRedirect(true);
return pageref2;
}
Any thoughts?
Thanks!
Is it possible to automatically create an ID upon loading of a visualforce page?
I was thinking about making the <apex:page "action="{!NewID}" > tag.. like the following:
public PageReference NewID() {
Object__c NewID = new Object__c (name = 'New Record');
insert NewID;
String changepage2 = '/apex/MyVF_Page?id='+NewID.Id;
PageReference pageref2 = new Pagereference(changepage2);
pageref2.setRedirect(true);
return pageref2;
}
Any thoughts?
Thanks!
The action method invoked when this page is requested by the server. Use expression language to reference an action method. For example, action="{!doAction}" references the doAction() method in the controller. If an action is not specified, the page loads as usual. If the action method returns null, the page simply refreshes. This method will be called before the page is rendered and allows you to optionally redirect the user to another page. This action should not be used for initialization.
let me know if you have any questions.
thanks,
RAmesh
I made some additional research and got all my questions answers by the exact same need on the link below.
http://bobbuzzard.blogspot.co.uk/2011/08/dml-during-initialisation.html