How can we hide the Activities formatter in SC_TASK Table

sajida3
Kilo Contributor

Hi Team,

I have a requirement ,In SC_TASK table how can we hide  Activities formatter field for Particular assignment group. i need to hide Highlighted part. i wrote Script include for

var GetAssignedToData = Class.create();
GetAssignedToData.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getAssignedTo: function() {

var sysID = this.getParameter('sysparm_sysID');

var g = new GlideRecord('sc_task');
g.addEncodedQuery('request_item.cat_item=189950c91b588d10a76243f0b24bcbfa^sys_id=' + sysID);
g.query();
if (g.next()) {
if (!gs.getUser().isMemberOf(g.assignment_group) && !gs.getUser().isMemberOf('Csir secure Group'))
return true;
else
return false;
}
},

i am hiding  variables and varibale sets. i need to hide Highlighted part.Please help me to resolve my issue.Thank you in Advance

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@sajida 

no direct method to hide that

You can either use view where that view won't have that activities filter and use view rule to show view based on your condition

But it won't happen on change of some field but only once when form loads

OR

you need to use DOM manipulation to show/hide it but DOM is not good practice

1) Ensure Isolate Script field is set to false for your client script

2) This field is not on form but from list make it false

find_real_file.png

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	// ajax code here
	document.getElementById('sn_form_inline_stream_entries').style.display = 'none'; // to hide

	document.getElementById('sn_form_inline_stream_entries').style.display = ''; // to show

}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

15 REPLIES 15

@Ankur Bawiskar 

Hi Ankur, 

I applied the same logic, now it is working as expected. But in my case i have one Business Rule

restricting the RITM's, when i activate the business rule catalog item fileld becomes empty then our

code is not working.

Business rule before Query

if(gs.getSession().isInteractive() && (!gs.getUser().isMemberOf('CSIR secure group') && !gs.getUser().isMemberOf('Csir non secure Group'))){
q=current.addEncodedQuery('cat_item.name!=Cyber Security Incident Form for Secure Group^cat_item.name!=Cyber Security Incident Form');
}

//Add the scenario if user is part of both the grops - If this is possible as per the current system

//RITM is visible to only CSIR secure group members - Secure Group admins
if ((gs.getSession().isInteractive() && gs.getUser().isMemberOf('CSIR secure group'))) {
}

//RITM is visible to all - Non secure group
if ((gs.getSession().isInteractive() && gs.getUser().isMemberOf('Csir non secure Group'))){
q=current.addEncodedQuery('cat_item.name!=Cyber Security Incident Form for Secure Group');
}

find_real_file.png

Hi,

logic to show/hide is shared in my script.

Please ensure you use that and use valid conditions when it should be shown etc

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

hanwar2_0-1735274025713.png

can you please  suggest how to hide Activities onLoad

sajida5
Kilo Explorer

Hi Ankur,

Below code is used for hiding Activities in sc_task(which you suggest),it is working when my BR is inactive,

when I activate the BR(catalog item field gets empty in SC_task so hiding of the Activities is not working)

this is the 

sajida5
Kilo Explorer

@Ankur Bawiskar 

Could you please help me to resolve the issue