-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPRedirectWithID not working #71
Comments
This function was always a bit of a hack. Basically, the page refreshes until the script sees that the item has been created (there's a new item since the Save button was pushed), and then the aspnewForm action is changed to redirect to the the target with the newly discovered ID. What you're seeing in your first screenshot is that interim state: the Source is set to the current page and RealSource holds the Source value SharePoint had set originally. I haven't ever tested this on SharePoint Online, to be honest. In theory it should work in a "classic" list's NewForm, but it's possible something has changed to make it not work. Let me see if I can replicate. |
OK, thanks. I just wanted to confirm that I wasn't using the API incorrectly. |
I've reproduced, and it looks to me like the action attribute is ignored for some reason. It may be that they saw this as a vulnerability and plugged that hole. I'll do a little more debugging... |
Yeah, from what I can see, action is now ignored, unless I'm missing something. The script to do the postback is more byzantine than ever, but I traced it pretty deep. All the right set up occurs when the NewForm loads, but the redirect I put into the action never happens. |
Thanks for investigating this. |
Sorry I don't have a better answer. |
I want to help on this project. |
is there any progress on this bug? I got the same problem that the redirection is not working at all with this script i could change the redirection behaving but i don't have the ID of the record which is much more important // for Save button button.removeAttr("onclick"); button.click(function() {
if (!PreSaveItem()) return false; |
What version of sharepoint is this. You can easily get the url using a api call to the service instead. You can also do an Update add or delete using the same logic of code with a post in JQUERY
$.ajax({ url: taskUrl, type: "POST", contentType: "application/json;odata=verbose", data: JSON.stringify(item), headers: { "Accept": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val(), }, success: function (data) { /* var ItemId = data.d.Id; var parts = document.getElementById("txtAttachment").value.split("\\") var filename = parts[parts.length - 1]; var file = document.getElementById("txtAttachment").files[0]; // uploadFile(ItemId,filename,file); */ window.location.href = "{url}"; }, error:function(data, status, xhr) { console.log(data); alert('task did not save'); } });
});
On Friday, November 22, 2019, 06:11:50 AM EST, MiracelVip <[email protected]> wrote:
is there any progress on this bug? I got the same problem that the redirection is not working at all
with this script i could change the redirection behaving but i don't have the ID of the record which is much more important
`$(document).ready(function () {
// for Save button
var button = $('input[accesskey="O"]');
button.removeAttr("onclick");
button.click(function() {
var elementName = $(this).attr("name");
var aspForm = $("form[id=aspnetForm]");
var oldPostbackUrl = aspForm.get(0).action;
var currentSourceValue = GetUrlKeyValue("Source", true, oldPostbackUrl);
var newPostbackUrl = oldPostbackUrl.replace(currentSourceValue, "https://departments.brueckner.com/shared/pro/NBD_BOPE/Lists/BOPE_interested_parties_contact/NewForm.aspx");
if (!PreSaveItem()) return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newPostbackUrl, false, true));
});
});`
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
This function was always a bit of a hack, and I haven't tried to maintain it over the years. Obviously, the version of SharePoint matters, but patches to the versions may have rendered this unusable. |
I get XHRPOSThttps://sharepoint.womicklawfirm.com/test3/_vti_bin/Lists.asmx |
I'm trying to redirect a user to the edit form after they submit an item in a new form. Here's the code I'm embedding into the new form:
In SharePoint Online the alert in the PreSaveAction function shows that the action attribute in the form has been updated but I still get redirected to the list view after the save.
In SharePoint 2013 (with MDS disabled) the alert in the PreSaveAction function shows that the action attribute in the form has not been updated so, as expected, I get redirected to the list view after the save.
I think I'm using SPRedirectWithID as directed in the documentation.
The text was updated successfully, but these errors were encountered: