Not Getting Error Info

ABC6
Tera Contributor

Hello Team ,
i am restricting ITIL user not to Delete attachment from manage attachment for table named "std_change_record_producer" .

To achieve this i have written a BR on sys_attachment table , everything is working fine but i am not been able to get Error info Message while removing the attachment,Please let me know where exactly i am doing wrong below are the code

 var user = gs.getUser();

    if (user.hasRole('itil') && current.table_name=='std_change_record_producer') {
            gs.addErrorMessage('ITIL User are not authorized to delete attachments from this record.');
            current.setAbortAction(true);  
        }
1 ACCEPTED SOLUTION

Viraj Hudlikar
Giga Sage

Hello @ABC6 

 

If I follow this KB article and when i implemented as per requirement it worked for me do try this. https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0825743

 

My BR is as below:

VirajHudlikar_2-1742212927215.png

VirajHudlikar_3-1742212948008.png

 


Me as system administrator can delete it

VirajHudlikar_1-1742212878042.png

 

Abel Tutor who has ITIL role cannot delete.

VirajHudlikar_0-1742212836166.png

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

View solution in original post

7 REPLIES 7

Shivalika
Mega Sage

Hello @ABC6 

 

Can you instead try with current.addErrorMessage() ? 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway,

 

Regards,

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

ABC6
Tera Contributor

Not Working

Hello @ABC6 

 

I think it's because we are restricting it and page is changing. Can you try setting redirect url as current after aborting the action ? 

 

Also try "Add message" under Actions tab. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway,

 

Regards,

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

ABC6
Tera Contributor

you are talking to use action.setredirect or how can we use it