0

Ii have created a simple trouble ticket system using a sharepoint list. I have created a dropdown menu with 5 differnet choices which correlates to the different types of issues that users may encounter. What information I need from the user will depend on their choice from the menu.

What I want is the simplest way possible to make it so that when they choose an option from the dropdown column, they are presented only with the columns that are relevant to their issue.

Ex: if the user chooses “Computer issues” from the dropdown, I want it so that the column that ask for the computer name shows up. If the user chooses “printer issues” from the dropdown, I want the “ provide printer IP” column to show up, but not the column asking for the computer name.

Edit: I don’t want to use multiple content types. I tried this for the past 2 weeks and y list would brake one way or another. I don’t mind using code if someone is willing to walk me through it step by step. I have sharepoint designers.

1

You could achieve this by using 5 different content types on the list. Each CT would only have the relevant fields.

  • I tried this, but it didn’t work the way I want it to. I want to use a single content type that will contain all the columns, then only the columns I want will show up. I don’t mind dealing with code if someone is nice enough to walk me through it. – maximo brito Apr 2 '18 at 22:12
  • You asked for the most simple way possible. So I guessed you don't want to have any coding involved. You complained at the code sample that you are unsure how to integrate it. So using different content types here sounds like the most simple option for me. For dynamic hiding you would need custom code – Heiko Hatzfeld_MSFT Apr 3 '18 at 17:24
  • Sorry for the misunderstanding. By simplest way, I meant that I want a way to just hide the columns, to some elaborate code to do something extra complicated. I don’t mind using code, I just would like some help implementing it because I have tried put get JS code into a webpart and into the source code for the site, but I didn’t make it work – maximo brito Apr 3 '18 at 17:44
  • I still would aim for a content type in this setup. You can have all 5 of them in a single list if you enable the management of content types for the list. If they all are children of the base CT, they can share your core fields. And in the view you will see all fields. – Heiko Hatzfeld_MSFT Apr 3 '18 at 18:20
  • This works only when creating the new items. But for some reason when you try to edit or even just open the created items, all I get is an blank page. No error, no nothing, just a blank page – maximo brito Apr 3 '18 at 20:54
1

Use JS to acheive the same. Hide both the fields and then show them on user selection:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function () 
{   
$('h3:contains("Computer Name")').closest("tr").hide();
$('h3:contains("Provide printer IP")').closest("tr").hide();

$( "[title^='DropDown Name']" ).change(function() {
    var SelectedVal=$("[title^='DropDown Name'] option:selected").val();
    if(SelectedVal=="Computer issues")
    {       
        $('h3:contains("Computer Name")').closest("tr").show();
        $('h3:contains("Provide printer IP")').closest("tr").hide();
    }
    else if(SelectedVal=="Printer issues")
    {   
        $('h3:contains("Computer Name")').closest("tr").hide();
        $('h3:contains("Provide printer IP")').closest("tr").show();
    }

});
</script>
  • Thank you for the code, but I am not sure how to use it, or were to use it. I am familiar with coding, but not so much with JS. Could you please step by step me through implementing this code? Also, Com what I can understand from this code, it seems that you have the columns hidden by default in the first lines of code. Why are you hiding them again in the if statements? – maximo brito Apr 3 '18 at 15:30
  • I have tried implementing this code, but I have no idea how to make it work – maximo brito Apr 3 '18 at 16:24
  • In new form, add a script editor web part and add the above code. Your understanding is correct. I am hiding the columns initially and then showing them based on user selection. – Deepmala Apr 4 '18 at 3:37
  • I did this. i clicked create "new item" and from the new form page i added a script editor webpart. I copied and pasted the code you gave me. the only thing that i changed was 'DropDown Name' to the actual name of my dropdown column. It didn't do anything. I even opened the new form in sharepoint designer and added the script directly into the code. – maximo brito Apr 5 '18 at 4:11
  • I hope you have added jquery reference. Check for errors in console. – Deepmala Apr 5 '18 at 4:41

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.