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

ersureshbe
Giga Sage
Giga Sage

Hi,

Can you refer below screenshot and yellow highlghted. You should drag and drop out of the form. It can achieved via Form Design

find_real_file.png

Please mark as correct answer if it helped.

Regards,

Suresh.

Regards,
Suresh.

Saurav11
Kilo Patron
Kilo Patron

Hello,

You cannot directly hide an activity formatter based on condition using client script or business rule.

You need to create a new view with all the fields but do not add Activity Formatter in it.

Then write a view rule that for the particular group it should always redirect to the new view created and for others it will take the default view.

find_real_file.png

Please mark answer correct/helpful based on Impact

sajida3
Kilo Contributor

@Ankur Bawiskar 

 

could you please help me to resolve this issue

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