- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2022 09:51 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2022 09:18 AM
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;
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;
Also make sure to set Isolate Script=false;
Hopefully this will resolve your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2022 09:18 AM
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;
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;
Also make sure to set Isolate Script=false;
Hopefully this will resolve your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2022 12:35 AM
Thanks Muhammad, that's a brilliant workaround.