How to hide attachments on incident form for end user if the attachment is attached by ITIL users

Rajesh Mushke
Mega Sage
Mega Sage

Hi All,

I want to hide attachments on incident form for end users if it is added by ITIL users/ any role users,


But still end users can attach the attachments and they can manage the attachments which are attached by end users.

Thanks in advance.!!!

Thanks,

Rajashekhar Mushke

Community Leader



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
1 ACCEPTED SOLUTION

Sample Script:

 

before query business rule on sys_attachment table.

 

(function executeRule(current, previous /*null when async*/) {
	
	// Add your code here
	
	if (!gs.hasRole('itil') && gs.getSession().isInteractive()) {
		var u = gs.getUserName();
		var q = current.addQuery('sys_created_by', u);
		q.addOrCondition('sys_updated_by', u);
		gs.log('query restricted for user: ' + u);
	}
	
	
})(current, previous);

 

you try something like this .

 

https://docs.servicenow.com/bundle/london-application-development/page/script/business-rules/concept...

 

https://www.servicenowguru.com/scripting/business-rules-scripting/controlling-record-access-before-q...

View solution in original post

7 REPLIES 7

Veer MS
Kilo Guru

Hi, Rajashekhar,

There are ACLs on sys_attachment table you might want to look at them & try restricting attachments from there.

For more info follow the below link:

https://community.servicenow.com/community?id=community_question&sys_id=7edb4be1db9cdbc01dcaf3231f96194d

Mark it as correct or helpful if this helps.

Thanks

Veer

Harsh Vardhan
Giga Patron

just curious to understand here, how if assignee will attach the attachment for end user? did you consider this point in your requirement? as you had mentioned end user (user without role ) can see only own attachment because it will would be some case that assignee want to send the resolution details on attachment so user can see and confirm the issue resolved or not. ( just adding my point here ).

did you try with query business rule?

Yeah good point bro, I will check with my customer, I haven't tried with query businss rule, please help on that Harsha Thanks for the response bro. Thanks, Rajashekhar Mushke


Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

Sample Script:

 

before query business rule on sys_attachment table.

 

(function executeRule(current, previous /*null when async*/) {
	
	// Add your code here
	
	if (!gs.hasRole('itil') && gs.getSession().isInteractive()) {
		var u = gs.getUserName();
		var q = current.addQuery('sys_created_by', u);
		q.addOrCondition('sys_updated_by', u);
		gs.log('query restricted for user: ' + u);
	}
	
	
})(current, previous);

 

you try something like this .

 

https://docs.servicenow.com/bundle/london-application-development/page/script/business-rules/concept...

 

https://www.servicenowguru.com/scripting/business-rules-scripting/controlling-record-access-before-q...