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

Hi,

not very sure on your instance configuration

the logic I shared you can check if the condition evaluates to true and add some alerts

Regards
Ankur

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

sajida3
Kilo Contributor

Hi Ankur,

Thanks for your help, Really it helps me to hide Activities in sc_task. But my BR overrides the Functionality,

It  empties the catalog item field so our logic gets failing. With BR it is working fine. In BR(I am

restricting  the request item for particular group).

 

 

 

how BR is overriding?

how is BR showing/hiding that activities filter

The code to show/hide is client side

I already mentioned the condition should be proper when you wish to hide it

Can you share what type of BR is that and what it is performing?

how does it relate to client script? are you using some scratchpad variable?

Regards
Ankur

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

sajida3
Kilo Contributor

Hi Ankur,

Actually My requirement is I need to restrict catalog item ,RITM and Tasks.

 

1.There is a  group  which is a 'secure group' who are part of this group they can only raise a request using

this item and they can only view the RITM other group members they can not view the RITM and raise a 

Request.

2.coming to SC_TASK who is member of that Assignment group they can only view that TASK.

 

I am able to restrict the ITEM(USER CRITERIA) and RITM (BUSINESS RULE) and i tried with ACL's but it is  not restricting the TASK.

Can you please help me to restrict the TASK.

Table:SC_TASK  *

var currentUser = gs.getUser();

 

gs.addInfoMessage("User is member of group: "+gs.getUser().isMemberOf(current.assignment_group.getDisplayValue()));

 

if(current.request_item.cat_item.name == 'CSIR Activity')//leave management system

{

if(gs.getUser().isMemberOf(current.assignment_group.getDisplayValue()))

{

answer = true;

gs.addInfoMessage("if: Restricting sctasks to added groups");

}

else{

gs.addInfoMessage("else: Restricting sctasks to added groups");

answer = false;
}

 

Regards,

Sajida

 

 

 

 

So this requirement is different than what's your original question?

If yes then please post a separate question and tag me in that.

 

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