0

SymMarc_Redirection

Regarding the above link by Marc, i would like to know, how to achieve this in a O365-SPO SPList.

i am facing this issue of redirection in my newform.aspx and i wanna redirect to editform.aspx with the EditForm.aspx?ID="newlycreatedID" As Marc mentioned the usage of DVWP in old versions of SP, but we cant use DVWP in SPO.(As far as i know) . Please correct me, if am wrong.

Am not using SPFx.

In my custom html content editor WP am writing the below line to open a new form with a ?source query string

   <td align="left" style="height:10px;color:black;font-weight: normal;">

      <a href="https://customsite/TestSite/Lists/splist1/NewForm.aspx?
    Source=https://customsite/TestSite/Lists/splist1/EditForm.aspx&ID=" 
    target="_blank">

   <p id="link1" style="color:blue;font-weight:bold;">Click here to open new 
       Form</p></a></td>
 <p>

I am unable to redirect to the editform with newly created ID here, with default, Save button click. how to achieve, load the editform with the values populating with the newly created ID.

1

You will either have to get the last item id from the list and then create the url or create a custom new form or override the save action such that you save the item first and then redirect to the edit form.

After your comment I can see that the URL you might be creating is wrong. I tried to create the url and succeeded y doing this: After getting the CurrentItemID, create the edit form url

var a = "https://sharepointr.sharepoint.com/sites/TeamSite/Lists/Test%20List/EditForm.aspx?ID="+ newlyCreatedItemID;

If you pass this url as source then it won't work after the "?" because the url will already have "?" in the form of "NewForm.aspx?Source=site/...." So , you need to encode the URL using the javascript function. Just pass the variable we create above to the encodeUriComponent function.

encodeURIComponent(a)

Now pass this encoded url as the source. So the New form url will look like this:

https://sharepointr.sharepoint.com/sites/TeamSite/Lists/Test%20List/NewForm.aspx?Source=https%3A%2F%2Fsharepointr.sharepoint.com%2Fsites%2FTeamSite%2FLists%2FTest%2520List%2FEditForm.aspx%3FID%3D5
  • am getting the last item generated/ newitem_id already.But the issue is that, am unable to redirect to editform.aspx?ID=myitemid . where, myitemid is the variabe i have declared. – SaMolPP Oct 18 '18 at 19:24
  • 1
    Its a built in javascript function. You can directly use it as i have mentioned. – harshal gite Oct 20 '18 at 11:01
  • 1
    For presaveaction, you will be able to manipulate the url using javascript but that will have no effect on clicking the save button. You can try once though. But initially what u did was create a button to go to the new page, that would do it for u. – harshal gite Oct 20 '18 at 11:04
  • 1
    If you want a solution which will not have any previous ID clashes if 2 requests are submitted at the same time then I would suggest you to create a custom form and save the item uaing rest or jsom. On success you get the Id of the newly created item and then you can use window.location to redirect. – harshal gite Oct 20 '18 at 13:54
  • 1
    I meant that you have the new form link on your home page right. On the home page itself, you can get the last item id from the list and then ++ it which will be the newly created if no 2 requests are submitted at the same time. Then you can use this created id in your link on the home page. – harshal gite Oct 21 '18 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.