You need to sign in to do that
Don't have an account?
Nakata
How to direct to custom object detail page ?
Good day,
I trying to redirect to a custom object(myObject) page when user click on the button from custom VF page, MyObject detail page having required fields which have set in page layout. what i need is do not manual set the required field value and insert myObject into DB before redirect, anyone have idea how can i fulfill this requirement ?
the whole purpose and intention is:
in pageA , when user click a button, it bring user to MyObject detail page and some preset value from pageA will carry and fill into MyObject detail page.
Thank you !
public PageReference doSelectContact(){ String contactId = ApexPages.currentPage().getParameters().get('selectedContactId'); if(StringUtils.isNotBlank(contactId)){ myObject= new myObject(); } //insert myObject;
PageReference myObjectPage= new ApexPages.StandardController(myObject).view();
myObjectPage.setRedirect(true); return myObjectPage; }
try to emitatethe URL which populate the field values in your details page on redirect.
Then pass that URL using Pagereference in your VisualForce Page.
See this email thread on how you can pre-populate some fields on a new record page (which is what I believe you're trying to do) - http://boards.developerforce.com/t5/Product-Discussion/Help-with-WIL/td-p/5882.
Hi Nakata,
I am pretty sure you are using the same controller where you are writing the doSelectContact() method behind the custom vf page where you have the link to navigate to the detail page of the object. If it so then use the default getter setter method of the varibles you need to insert. when you click the link, the page ll be posted and ll call the default setter method. Then set the values to the corresponding fields of the object from the varibles used in the vf page and insert the record. Then redirect the page to the detail page of the recently created record.
Thanks All for the help, i used WIL and get solved !
the code sample like below, that's prompt me another question, how can we get the URL "/a0v/e" dynamically in different environment ? i wish not to hardcode it ...
Hi Nakata,
Use the following code to dynamically create the URL
Hope this will help you.
Thanks,
Samar
Many thanks Samar for the enlightenment !
what about field id like '
'
can we get it dynamically as well ?