My homepage has an embedded view of a list called Project Info which displays important project information. One of the fields is a choice field called ProjectStatus
which can read either Pending, Active or Awaiting Approval. I want to selectively hide and display a pair of promoted links web-parts depending on the currently displayed contents of the Choice field.
I managed to accomplish something similar with hidden LVWPs based on another choice field called ProjectPhase
using the code below but this method will not allow for a range of choices:
<script type="text/javascript">
var ProjectPhase = document.querySelector("table[summary='Project Info Log ']").innerText.match(/Phase [1-9]/g)[0]
switch(ProjectPhase) {
case "Phase 1":
document.getElementById("MSOZoneCell_WebPartWPQ10").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ4").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ11").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ5").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ12").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ6").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ13").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ7").style.display = 'none';
break;
case "Phase 2":
document.getElementById("MSOZoneCell_WebPartWPQ9").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ3").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ11").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ5").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ12").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ6").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ13").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ7").style.display = 'none';
break;
case "Phase 3":
document.getElementById("MSOZoneCell_WebPartWPQ9").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ3").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ10").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ4").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ12").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ6").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ13").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ7").style.display = 'none';
break;
case "Phase 4":
document.getElementById("MSOZoneCell_WebPartWPQ9").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ3").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ10").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ4").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ11").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ5").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ13").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ7").style.display = 'none';
break;
case "Phase 5":
document.getElementById("MSOZoneCell_WebPartWPQ9").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ3").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ10").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ4").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ11").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ5").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ12").style.display = 'none';
document.getElementById("MSOZoneCell_WebPartWPQ6").style.display = 'none';
}
</script>
Can anyone suggest how I can modify this to work with a choice field with the following options: Pending, Active, Awaiting Approval, On Hold, Cancelled, Completed?
ProjectPhase
or different? Also you want to merge the conditions of two choice fields or just add conditions for your second choice field and remove conditions ofProjectPhase
? – Ganesh Sanap Aug 8 '19 at 8:16