Redirect to display view
-
- Posts: 10
- Joined: Mon Sep 25, 2017
Hi,
I'm assuming this is probably super simple, but I've searched the forum and tried several things and I can't figure it out.
How would I redirect back to the display form after clicking save or cancel on the edit form? I tried using this as the redirect URL but it always sends me to the same display form and not the one I was on:
/xxx/Lists/xxx/fd_Item_DisplayForm.aspx?{ItemId}
Thanks,
Jim
I'm assuming this is probably super simple, but I've searched the forum and tried several things and I can't figure it out.
How would I redirect back to the display form after clicking save or cancel on the edit form? I tried using this as the redirect URL but it always sends me to the same display form and not the one I was on:
/xxx/Lists/xxx/fd_Item_DisplayForm.aspx?{ItemId}
Thanks,
Jim
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hello, James!
Check out this article - https://spform.com/buttons/open-edit-fo ... sharepoint
You'll just need to replace in your code Edit Form for Display Form and you are good. Something like this should do:
Place it into the JavaScript editor, not on the Save button,
Check out this article - https://spform.com/buttons/open-edit-fo ... sharepoint
You'll just need to replace in your code Edit Form for Display Form and you are good. Something like this should do:
Code: Select all
fd.onsubmit(function() {
var uri = fd.setUrlParam(decodeURIComponent(window.location.href), 'FDRedirectWithID', 'fd_Item_DisplayForm.aspx?ID=');
fd.sourceFormParam(uri);
return true;
});
Cheers
-
- Posts: 10
- Joined: Mon Sep 25, 2017
Thanks Nikita,
Unfortunately inserting the above into the JavaScript editor just redirects me to the edit page
Unfortunately inserting the above into the JavaScript editor just redirects me to the edit page
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hello, James!
That's strange, I've just tested the code and it worked for me. Can you tell me the version of SharePoint and Forms Designer you are using?
That's strange, I've just tested the code and it worked for me. Can you tell me the version of SharePoint and Forms Designer you are using?
Cheers
-
- Posts: 10
- Joined: Mon Sep 25, 2017
Hi Nikita,
We are on SharePoint Online (Office 365), forms designer client 3.1.4
Thanks,
Jim
We are on SharePoint Online (Office 365), forms designer client 3.1.4
Thanks,
Jim
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Okay, same for me. What about the Form itself? Do you open it normally or perhaps it's opened in dialog mode, as a pop-up window? Can you provide some screenshots of how you open the form and how it redirects you to the Edit page? Maybe I'll see something that causes it.
Cheers
-
- Posts: 10
- Joined: Mon Sep 25, 2017
Nope, it opens in full screen (not dialog).
Here is where I inserted the code:
Here is the edit screen before I click save: Here is where it redirects. Same form, in edit mode. It does refresh the screen so I know it is doing something:
Here is where I inserted the code:
Here is the edit screen before I click save: Here is where it redirects. Same form, in edit mode. It does refresh the screen so I know it is doing something:
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Okay, it might sound obvious, but it seems that you have several tabs. Is there any chance that there are mandatory fields in other tabs that are left empty? In this case, the page will reload, but will not submit and won't redirect you to display form.
You can try adding this code to your Form, it will redirect you to the tab with the error, if there are any:
You can try adding this code to your Form, it will redirect you to the tab with the error, if there are any:
Code: Select all
function checkTabsForErrors(){
if($('span[role="alert"]').text()){
var error = $('span[role="alert"]').first();
openTabs(error);
}
}
checkTabsForErrors();
function openTabs(element){
var correctTab = element.parents('.ui-tabs-panel')[0];
var tabId = correctTab.id;
var IdAndTab = tabId.split('-tab-');
var ID = IdAndTab[0].split('-')[1];
$('#' + IdAndTab[0]).tabs('option', 'active', IdAndTab[1] - 1);
if (ID > 0){
openTabs($('#' + IdAndTab[0]));
}
}
Cheers
-
- Posts: 10
- Joined: Mon Sep 25, 2017
Thanks. Still no luck. I added the code and it didn't show any errors on other tabs. As an extra precaution, I changed it so that no fields were mandatory. I also tried the redirect code on another form and I get the same result.
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
And if you remove the code? Will you be able to save the item normally without redirection?
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 8 guests