You need to sign in to do that
Don't have an account?
KS Kumaar
how to open detailed edit page of a record using button click in visual force
I have a Vf page which display account object records. In this vf page each and every record have a button called Edit. If we click on Edit button it should be take us to detailed edit page respected record. For more clearance see my pictures which i uploded.
To achive this process, I have developed following VF page.
<apex:page Controller="Redirect_Main2" action="{!Redirect_Main}"> <apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!accs}" var="a" > <apex:column value="{!a.Id}"/> <apex:column value="{!a.Name}"/> <apex:column value="{!a.Phone}"/> <apex:column value="{!a.Industry}"/> <apex:column id="two"> <apex:commandButton value=" Edit " onclick="window.open('/{!a.id}')" reRender="two"/> <!--/e?retURL=%2F{!a.id}&_CONFIRMATIONTOKEN=VmpFPSxNakF4Tmkwd055MHlPVlF3T1Rvek5qb3dPQzQ0TnpaYSxvTFl3eklmdmNBcjl6RlVDeDRWUnBtLE9XWTJNbU01&common.udd.actions.ActionsUtilORIG_URI=%2F{!a.id}%2Fe')" reRender="two"/> --> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>Controller:
public class Redirect_Main2 { public List<Account> accs { get; set; } public PageReference Redirect_Main(){ accs = [select id,name,phone,Industry from account]; return null; } }
But this is taking me to detailed page of the record but not edit page. Please tell me neccessary actions which i need to take.
Thanking you
KS Kumaar
After saving the record it'll redirect you to home page because there is no return url in current URL.
So for redirecting it to detail page you must have to set record Id on retURL attribute.
try this one:
All Answers
you can also use like below to achive the functionality
Let me know if it helps.
Thanks
D Naveen rahul.
It need a little change on your CommandButton : use the above code it'll work.
Thanks
Viru
Its working good. But once i save the record, page is redirecting to some another page.
can not going to detailed page.
After saving the record it'll redirect you to home page because there is no return url in current URL.
So for redirecting it to detail page you must have to set record Id on retURL attribute.
try this one:
Hi Virendra Chouhan,
I got a doubt. Could you please explain it.
As you said i change modification in commandbutton by using return url like and it is working good.
But i found another return which is just used %2F like below and and it is also working good.
So, what my doubt is what is the differnce between both URLs even they are giving same result rather than changing URLs while getting saved?
you provide : <apex:commandButton value=" Edit " onclick="window.open('/{!a.id}/e')" reRender="two"/> this code for Edit mode.
Can you share code for View mode