0

We are using some Javascript customizations for SharePoint list items. My boss does not like the fact that we have three forms to choose from (edit, new, and display) and wants the user to be able to click the list item Title link and go directly to the Edit form. It is too much trouble (I guess) for the users to select what they want to do.

I found what I thought was a method located in https://www.sharepointdiary.com/2015/09/open-sharepoint-list-items-in-edit-mode-by-default.html but it didn't work. I suspect likely because this is a classic page I am working with and this code is for the online version.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() 
{
  //Change display form links to edit form links
  $('.ms-vb a[href*="listform.aspx"]').each(function(){
      var url = $(this).attr('href');
      url = url.replace("PageType=4", "PageType=6");
      $(this).attr('href', url);
  });
});
</script>

So, the question is this...is it possible to default a selected list item to open the Edit form and how might this be done?

Seems there might be a way to "route" to the Edit form but not sure.

Thanks.

17
  • The code is for Classic form. You can Return to classic SharePoint in SharePoint online. Feb 8 at 20:19
  • This is for SharePoint 2013 not SharePoint online...sorry for not specifying that.
    – Pablo
    Feb 8 at 20:20
  • Are you getting any error? What is happening if you add this code to your view page as described in the article? Feb 8 at 20:40
  • I just tested in SharePoint 2013 and it worked perfectly for me (without changing a char) Feb 8 at 20:44
  • I don't get any error. Tried running the code in the console and what it seems in SP13 there is no .ms-vb selector as the object comes back with zero length. Was trying to find out which selector to use instead of .ms-vb but was not able to find something.
    – Pablo
    Feb 8 at 20:44
0

The code in the original question works perfectly. The issue I had was I had in my head to add the Script web part in the Display form which is after the Display form has opened when it really needs to be added to the List View so when the user clicks the Title url to open the page in Display Mode (the default mode) it get rerouted with the Jquery to open in Editor mode.

This also explains why when running the code in the console I was unable to find the selectors because I was looking in the Display form. Doh!

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.