You need to sign in to do that
Don't have an account?
Redirecting to tabbed VF page after record deletion
Hey there,
I have recently solved a problem that has hounded me for weeks and that was how to re-direct to a certain tab in my tabbed VF accounts page after creating a new record (a child object to accounts). Immediately I have come across another problem and that is how to override the delete record button so that it will either(whichever is easier and/or quicker/simpler on the VF page):
A: Re-render the pageblock list of the records with the record deleted...without redirecting away from the page.
B: re-direct using the code that I have just used with the new records..but re-direct to the current tab.
Obviously, I feel that simply re-rendering the list will be more efficient and easier...i am just not 100% sure on where to even start. please help.
Mikie
All right mate here are the codes as I promised:
here is the VFPage i created to help you out
now here is the extension:
sorry for taking a little longer, i forgot about the setredirect(true) therefore my data wasn't getting refreshed.
I hope this helps you out mate!
All Answers
Mikie, I say you should look into reRender and Action region.
Look at this and hope this help you out:
http://salesforceonlinetrainings.blogspot.com/2012/09/add-dynamic-re-rendering-visualforce.html
http://harshesh7487.blogspot.com/2011/09/rerender-using-action-support-in.html
and here is another good place to start
http://boards.developerforce.com/t5/Visualforce-Development/ActionRegion-amp-Awkwardly-Displayed-InputField-Label/td-p/296029
Thanks buddy, will have a look through these and mark as solution if I can find the answer in here.
Was not able to find my solution in there. I need something along the lines of:
Overiding the delete button so that it will refresh the current page (right down to the tab that is open) or just re-render the record list of the record that just got deleted with the record that just got deleted no longer in it. Does this make sense? Is it a possiblity?
I have attempted it, but each time when actually trying the delete button out I get : Id value 001N000000819na is not valid for the Fact_Finder__c standard controller.
I followed isntructions, but I think I did them wrong.
I overrode the Fact_finder__c delete button with this VF page:
and this is the controller:
I have attempted to make it similar to my save extension which works and is this:
Sorry for getting back late, but i have some questions:
1. You have a custom Account Page and it has a tabbed with Fact Finder?
2. Are you pulling the Fact Finder into a page block table or a list?
3. Are you deleting this record from the fact finder detail page that is out of the box, and you want to redirect it to the Account page?
4. Or are you deleting it from the Account Page and you want to redirect it?
Can you provide you Account VF page?
Also, if your fact finder is in the Account Page and the results are being shown based on the page block table, you can easily create a new parameter that allows you just delete that record and refresh the page after deletion. Let m eknow what you have and i'll see what i can come up with.
Not at all man, you are helping me and I am willing to work around you.
1 & 2: I think the answer is yes and into a pageblocktable, this is the fact Finder section of my Accounts VF page my code:
3 & 4:. So, I have overridden the delete button from the Fact_Finder__c object and when I test it out, I am clicking the delete that is found, when I am on the Fact_Finder__c tab and I have clicked one of the records and the bottom half of the tab re-renders with the details of the record (detail is identical to what you would see should you look at the standard apge layout). I click the standard delete button at the top in the middle of the details page. Then I want it to re-direct to my accounts vF apge ( PageReference pageRef= new PageReference('/apex/DestinyAccount?id='+fac.account__c+'&Sfdc.override=1');
pageRef.getParameters().put('tab','FactFinder');.
Although, officially I am deleting it from the Accounts page, I still think that it is considered me deleting from the Fact_Finder page as it is rendered onto the page.
Here is my code:
Thank you so much for your help!
Ps. This line pageRef.getParameters().put('tab','FactFinder' works with this line in the VF page:
to re-direct to the tab of the record that was just deleted....there is probably an easier way to do this...
You are an absolute legend mate!
All right mate here are the codes as I promised:
here is the VFPage i created to help you out
now here is the extension:
sorry for taking a little longer, i forgot about the setredirect(true) therefore my data wasn't getting refreshed.
I hope this helps you out mate!
Hey, thank you so much for your help. I just had a few questions...
1. Would I need a separate extension for every custom object or just the one which I add to?
2. I attempted to change it for fact_finder__c except it would not work so I just left it as contact and it deletes fine. But, will this same extension work for my other custom objects?
3. Would my tab redirection statements work in the extension so that it will re-direct to the right tab of the VF page? ( pageRef.getParameters().put('tab','FactFinder');)
Thank you for your help and time.
2 the reason why it didn't work fact finder because you probably not querying the fact finder record. So in my example, I have contacts I have the id of that record but I had to query the record then delete. Maybe I should have made it for more dynamic. Let me see if I can get it more dynamic and I'll send it to you.
3 it should be fine.
You are the man, already tested it out and the tab re-directing formula does work. So sweet, its also good that I wont need a million extensions. Will it work with the same broad extension, or will it be an extension that has a bit added for every object that I add the delete button to?
Hey Eric, I have had a little play around and have managed to have the extension Delete two separate records with the same extension. I was hoping you could have a look at this to tell me how I have went. Does the extension look alright to you?
I really feel like I have gone up levels in my coding abilities from the few times you have helped me so thank you. Let me know what you think.
Final code all because of you mate. Tell me what you think
Couldnt have done it without you mate