Redirect to Display Form after Saving (the generic way)
Hi,
is it possible to build some generic function for the redirect to the display form after editing an element?
Something like in documentation:
But here it has the "fd_Item_Edit.aspx". How to build it to be dynamicly to the content type (e.g. "fd_Contact_Display", "fd_Request_Display.aspx").
Or maybe it is possible to place a string inside the "general" option for the form, redirecting to the display form.
Right now i've build this:
But this only works good in edit-form, to redirect to display form.
If i us this code in new-form, i'll receive an error...
is it possible to build some generic function for the redirect to the display form after editing an element?
Something like in documentation:
Code: Select all
fd.setUrlParam(window.location.href, 'FDRedirectWithID', 'fd_Item_Edit.aspx?ID=');
Or maybe it is possible to place a string inside the "general" option for the form, redirecting to the display form.
Right now i've build this:
Code: Select all
fd.onsubmit(function() {
fd.sourceFormParam(document.referrer);
return true;
});
If i us this code in new-form, i'll receive an error...
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear ragesoft,
Regarding dynamic form - only if you can get the name of the content type to construct the name of the form. You can add Content Type field on the form, hide it by setting its Style to:
And then using the following code to get its text value:
Regarding the second option, with document.referrer - I do not recommend using it, and as you've noticed it doesn't work at all with the New Form. I actually don't think it will work if you open the Edit Form directly from the List View either.
Regarding dynamic form - only if you can get the name of the content type to construct the name of the form. You can add Content Type field on the form, hide it by setting its Style to:
Code: Select all
display:none;
Code: Select all
fd.field('ContentType').control()._el().find("option:selected").text();
Cheers
Thx for the tipp.
I've now build this one:
So on "New" form the "FDRedircetWithID" is used, on Edit-Form the current Item id is used.
I've placed a button in the display form to add related items in a dialog:
If i click the button i recive an error like
the problem is related to the "&ID=42" parameter, added to the url call.
Where dos it come from?
If i add the "ID" as popup parameter to the dialog options, it works, because the "ID" param is set to nothing.
it seems, the opendialog adds all available parameters from parent to the dialog...
I've now build this one:
Code: Select all
fd.onsubmit(function() {
var uri = _spPageContextInfo.webAbsoluteUrl + listName + displayForm;
if(fd._formType() == "Edit"){
uri = fd.setUrlParam(uri, 'ID', fd.getUrlParam(window.location.href, 'ID'));
}else{
uri = fd.setUrlParam(uri, 'FDRedirectWithID', displayForm + '?ID=');
}
fd.sourceFormParam(uri);
return true;
});
I've placed a button in the display form to add related items in a dialog:
Code: Select all
// open target form and set parent parameter
fd.openFormInDialog(webUrl + listNewForm,{"OMSParent":parentId},function(){});
Code: Select all
"Something went wrong"
"cant find item under 'https://myportal.de/sites/admin/Lists/Networkinterfaces/fd_OMSNetworkInterface_New.aspx?IsDlg=1&FDSource=https://myportal.de/sites/admin/Lists/Systems/fd_OMSSystem_Display.aspx?ID=42&Source=https://myportal.de/sites/admin/Lists/Systems/fd_OMSSystem_Display.aspx?ID=42&ID=42&OMSParent=42&IsDlg=1' "
Where dos it come from?
If i add the "ID" as popup parameter to the dialog options, it works, because the "ID" param is set to nothing.
Code: Select all
{"OMSParent":parentId,ID:''}
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Ragesoft,
Can you please show me the rest of the code here?
Just want to know how you get these values, so I can test it myself.
Can you please show me the rest of the code here?
Code: Select all
// open target form and set parent parameter
fd.openFormInDialog(webUrl + listNewForm,{"OMSParent":parentId},function(){});
Cheers
Here the full code for the "onclick" event of button:
i "fixed" it with this code in the "onsubmit" funciton of the form:
It seems, the additional "List" and "Source" parameter in the url fixing the problem...
Code: Select all
var parentId = fd.getUrlParam(window.location.href, 'ID');
var webUrl = _spPageContextInfo.webServerRelativeUrl;
var listNewForm = "/Lists/Drives/fd_Drive_New.aspx";
if(fd._formType() == "New" || parentId == ""){
parentId = fd._tempParentId();
}
// open target form and set parent parameter
fd.openFormInDialog(webUrl + listNewForm,{"OMSParent":parentId},function(){});
Code: Select all
var displayForm = "fd_System_Display.aspx";
var listName = "/Lists/Systems/";
fd.onsubmit(function() {
var source = fd.getUrlParam(window.location.href, 'Source');
var list = fd.getUrlParam(window.location.href, 'List');
var uri = _spPageContextInfo.webAbsoluteUrl + listName + displayForm;
uri = fd.setUrlParam(uri, 'Source', source);
uri = fd.setUrlParam(uri, 'List', list);
if(fd._formType() == "Edit"){
uri = fd.setUrlParam(uri, 'ID', fd.getUrlParam(window.location.href, 'ID'));
}else{
uri = fd.setUrlParam(uri, 'FDRedirectWithID', displayForm + '?Source=' + source + '&List=' + list + '&ID=');
}
fd.sourceFormParam(uri);
return true;
});
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests