Redirect after Save/New with MainView and Entity Page

Posted by Diane Kohnert on February 19, 2010
Blog

Redirect with Save and Save/New
Using a Redirect after doing a save or save/new is pretty straight foward. The main difference to remember is whether your doing a redirect to a quickform MainView or doing a redirect to a quickform tied to an Entity Page.

For this example, I have a quickform called InsertRealEstate.ascx with an associated EntityPage called InsertRealEstate.aspx. The user has 2 save options: 1) Save which takes the user back to a RealEstate MainView with the RealEstateDetails.ascx quickform in the MainContent or 2) Save/New which takes the user back to the same InsertRealEstate.ascx quickform in the InsertRealEstate.aspx EntityPage.

Option 1: Redirect to MainView
For the first example, the save button calls a business rule that does a save. Then there is an ‘OnCompleteActionItem’ that actually does the Redirect. Here is a picture of what that would look like:

Lets take a look at the properties that are filled in for the redirect. The MainViewEntityName is set to RealEstate and the MainViewEntityMode is set to Detail. This will actually take us to the MainView for the RealEstate entity. In this case we are redirected to the RealEstate.aspx that contains the RealEstateDetail.ascx quickform in the MainContent. We also chose ‘Use Current Link in ID’ set to True as we want the Current ID to be included in the redirect. If you looked at the code behind that button you would see the code generated is something like this:
Response.Redirect(string.Format("RealEstate.aspx?entityId={0}", (this.BindingSource.Current as Sage.Platform.ComponentModel.IComponentReference).Id));
This actually redirects us to the RealEstate MainView and displays the record we just saved.

Option 2: Redirect to EntityPage
For the second example, has to do with the save/new button. The save/new button calls a business rule that does a save. This time we want to stay on the same page to add another record. We will still use the ‘OnCompleteActionItem’ to do the Redirect. Here is a picture of what that would look like:

In this case the properties used are the URL and the ‘Use Current Link in ID’ set to false. The URL is pointing to the InsertRealEstate.aspx Entity Page with a parameter added of modeid=insert
InsertRealEstate.aspx?modeid=insert
The ‘Use Current Link in ID’ is set to false because we don’t really need to see an ID if we are going right back to add another RealEstate record. The MainViewEntityName and MainViewEntityMode is not used in this case because we are not wanting to go to the MainView for the RealEstate Entity, instead we want to go to the EntityPage that we are currently on: InsertRealEstate.aspx.

If we take a look at the code generated for this we would see another Redirect without an ID in the URL
Response.Redirect(string.Format("InsertRealEstate.aspx?modeid=Insert"));

Hope this explains the working of the Redirect when used with a MainView and with an Entity Page.

Tags: , , ,

No comments yet.

Leave a comment

WP_Big_City