Redirect from Display Form immediately

Hello community,
Need help with redirection after clicking on the list item to Display a Form. I need the people to be immediately redirected to Edit Form.

Here is the code - when I log the URL to the console, it works, but when I open the list item in Display Form, it won't do anything. It does not redirect me.

fd.spRendered(function(result) {

var listId = fd.spFormCtx.ListAttributes.Id;
var itemId = result.itemId;
//replace "https://domain.sharepoint.com/sites/sitename/subsite" with path to your site
//PageType=6 means Edit Form
result.RedirectUrl =
"https://sharepoint.{domain}.{eu}/apps/{subsite}/_layouts/15/listform.aspx?PageType=6&ListId="
+ listId + "&ID=" + itemId;
console.log(result);
console.log(result.RedirectUrl);
});

Thank you for your help.
Steo

Dear @Stepan,
Something like should be enough for simple redirect, you don't need anything else:

var itemId = fd.itemId; 
var listID = fd.spFormCtx.ListAttributes.Id;
window.location.href = 'https://domain.sharepoint.com/sites/sitename/_layouts/15/listform.aspx?PageType=6&ListId=' + listID + "&ID=" + itemId;
2 Likes

It works :slight_smile: Thank you.