Redirect URL to get from UIForm back to the UIGrid after Save

Andrei Panait asked on March 23, 2017 10:35


I have a form (New/Edit Object Template) under the following nodes:

Content management > Pages > Edit > CustomApplication > CustomClassListing > New Custom Class

I have an Extender for the UIForm in order to set the correct DocumentID/NodeID on the custom class. After saving I want to get redirected back to the listing. I tried using the UIContextHelper.GetElement to figure out the parameters, but I had no success so far.

What is the correct way of going back from the UIForm to the corresponding UIGrid?

Thank you.

Correct Answer

Suneel Jhangiani answered on March 23, 2017 11:15


string url = UIContextHelper.GetElementUrl(moduleName, ElementName, displayTitle, objectId);

The moduleName shoule be the CodeName of your Module where you defined the UI for the object listing.

ElementName is the codeName of the UI element where the listing is.

ObjectId allows for a paramter to be passed.

If your listing uses additional parameters then you can pass them in by adding paramters to the Url:

string redirectToUrl = UIContextHelper.GetElementUrl(MyCustomModule.MODULE_NAME, "ShipmentProperties", false, ShipmentID);

            if (mOrderId > 0)
                URLHelper.AddParameterToUrl(redirectToUrl, "orderid", mOrderId.ToString());
            if (mCustomerId > 0)
                URLHelper.AddParameterToUrl(redirectToUrl, "customerid", mCustomerId.ToString());

EDIT: I just noticed that the code above is a bit wrong since URLHelper.AddParamter(redirectToUrl, "orderid", mOrderId.ToString()) returns a string with the new parameter added and hence you should replace 'redirectUrl' with this new value ie. redirectUrl = URLHelper.AddParamter(redirectToUrl, "orderid", mOrderId.ToString())

1 votesVote for this answer Unmark Correct answer

Recent Answers

Andrei Panait answered on March 27, 2017 18:14

For reference, the final solution for redirecting from UIForm back to the Object Listing when these are found in a Page tab was to set the Redirect URL as:

{%UIContext.GetElementUrl("ModuleCodename", "UIElementCodename", false, 0, "nodeID="); @%}{%nodeid%}

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.