How to hide attachment to end users based on incident category?

Veronica3
Tera Expert

Hi All,

we need to hide attachments to callers only for records related to a specific category on the incident table.

For example: If the incident category is "Hardware", then attachments added by operators on the incident must be hidden for the caller.
If the incident category is "Software", then attachments added by operators on the incident must be visible to callers.

We have noticed that there is a "Table_sys_id" field on the "sys_attachment" table that identifies which record the attachment was added to, but we cannot use it to retrieve the incident category.

Do you have any suggestions?

thanks

1 ACCEPTED SOLUTION

Thank you very much for your reply.
Unfortunately, applying this script generates an infinite loop which has slowed down the performance of the instance considerably.


To resolve our situation, we intervened directly on the portal widget that shows the Attachments to hide them from users.

View solution in original post

2 REPLIES 2

Murthy Ch
Giga Sage

Hi @Veronica

Can you try something like this:

Condition:

if (!gs.hasRole('itil') && gs.getSession().isInteractive())

Code:

(function executeRule(current, previous /*null when async*/ ) {
    var grA = new GlideRecord("sys_attachment");
    grA.addEncodedQuery("table_name=incident");
    grA.query();
    while (grA.next()) {
        var gr = new GlideRecord("incident");
        if (gr.get(grA.table_sys_id)) {
            if (gr.category.getDisplayValue() == "Hardware") {
                current.addQuery("sys_created_by", gs.getUserName());
            }
        }
    }

})(current, previous);

It works, tested in my PDI but i feel ACL would be more prefarable rather than BR.

 

Thanks,

Murthy

Thanks,
Murthy

Thank you very much for your reply.
Unfortunately, applying this script generates an infinite loop which has slowed down the performance of the instance considerably.


To resolve our situation, we intervened directly on the portal widget that shows the Attachments to hide them from users.