Hiding "System" activities from activity list.

Sourin1
Tera Contributor

Hi,

I want to hide the "System" activities from the activity list in the sc_task form for a given group. How this can be achieved? Please refer the attachment for more clarification. I want to hide all these kind of activities from System.

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage
Mega Sage

Hi Sourin,

 

Consider it as a workaround to fulfill your requirement because it is not a recommended way and might lead to problems in future upgrades to an instance which might require some manual resolution. But anyways, I have tested this on incident table of my PDI and it is working. Follow these steps;

1. Create a client callable script include, make sure to replace Practice First Group with your group name, and also name your script include and function appropriately.

var CommunityAnswerHideSomeActivities = Class.create();
CommunityAnswerHideSomeActivities.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	isLoggedInUsermemberOfGroup: function(){
		if(gs.getUser().isMemberOf('Practice First Group')){
			return true;
		}
		else{
			return false;
		}
	},

    type: 'CommunityAnswerHideSomeActivities'
});

Image for reference;

find_real_file.png

 

2. Create an onLoad() Client Script on your Catalog Task [sc_task] table;

function onLoad() {
   //Type appropriate comment here, and begin script below
   
	var ga = new GlideAjax('CommunityAnswerHideSomeActivities'); 
	ga.addParam('sysparm_name','isLoggedInUsermemberOfGroup'); 
	ga.getXML(ResponseFunction); 
	
	function ResponseFunction(response) { 
		var answer = response.responseXML.documentElement.getAttribute("answer"); 

		if(answer == 'true'){
			var elements = document.getElementsByClassName("h-card h-card_md h-card_comments");

			var activitiesCounter = document.getElementsByClassName("activity-stream-label-counter");

			var str = activitiesCounter[0].innerText;
			var array = str.split(' ');

			var totalActivities = parseInt(array[1]);

			for(var i=0; i<elements.length; i++)
			{
				if(elements[i].innerHTML.indexOf("System") > -1 && elements[i].innerHTML.indexOf("System ") == -1)
				{
					elements[i].style.display = 'none';
					totalActivities = totalActivities - 1;
				}
			}

			activitiesCounter[0].innerText = "Activities: " + totalActivities.toString();
		}
	}
	
}

 

Image for reference;

find_real_file.png

find_real_file.png

Also make sure to set Isolate Script=false;

find_real_file.png 

Hopefully this will resolve your query.

View solution in original post

2 REPLIES 2

Muhammad Khan
Mega Sage
Mega Sage

Hi Sourin,

 

Consider it as a workaround to fulfill your requirement because it is not a recommended way and might lead to problems in future upgrades to an instance which might require some manual resolution. But anyways, I have tested this on incident table of my PDI and it is working. Follow these steps;

1. Create a client callable script include, make sure to replace Practice First Group with your group name, and also name your script include and function appropriately.

var CommunityAnswerHideSomeActivities = Class.create();
CommunityAnswerHideSomeActivities.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	isLoggedInUsermemberOfGroup: function(){
		if(gs.getUser().isMemberOf('Practice First Group')){
			return true;
		}
		else{
			return false;
		}
	},

    type: 'CommunityAnswerHideSomeActivities'
});

Image for reference;

find_real_file.png

 

2. Create an onLoad() Client Script on your Catalog Task [sc_task] table;

function onLoad() {
   //Type appropriate comment here, and begin script below
   
	var ga = new GlideAjax('CommunityAnswerHideSomeActivities'); 
	ga.addParam('sysparm_name','isLoggedInUsermemberOfGroup'); 
	ga.getXML(ResponseFunction); 
	
	function ResponseFunction(response) { 
		var answer = response.responseXML.documentElement.getAttribute("answer"); 

		if(answer == 'true'){
			var elements = document.getElementsByClassName("h-card h-card_md h-card_comments");

			var activitiesCounter = document.getElementsByClassName("activity-stream-label-counter");

			var str = activitiesCounter[0].innerText;
			var array = str.split(' ');

			var totalActivities = parseInt(array[1]);

			for(var i=0; i<elements.length; i++)
			{
				if(elements[i].innerHTML.indexOf("System") > -1 && elements[i].innerHTML.indexOf("System ") == -1)
				{
					elements[i].style.display = 'none';
					totalActivities = totalActivities - 1;
				}
			}

			activitiesCounter[0].innerText = "Activities: " + totalActivities.toString();
		}
	}
	
}

 

Image for reference;

find_real_file.png

find_real_file.png

Also make sure to set Isolate Script=false;

find_real_file.png 

Hopefully this will resolve your query.

Thanks Muhammad, that's a brilliant workaround.