How to make the attachment read only and cannot be deleted for SC_TASK table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 04:55 AM
How to make the attachment read only and cannot be deleted for SC_TASK table.
We have a requirement that user should be able to attach any attachment on the record in sc_task table, but cannot delete it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 05:35 AM
Hi @Rohit Reddy ,
Hope you are doing great.
To fulfill the requirement of making attachments read-only and preventing their deletion for the "sc_task" table in ServiceNow, you can follow the steps outlined below:
Navigate to the "sc_task" table in the ServiceNow instance.
Access the table's dictionary by clicking on "System Definition" > "Tables & Columns" > "Dictionary".
Search for the field that represents the attachment functionality on the "sc_task" table. The default field name for attachments is usually "u_attachment".
Once you locate the field, click on its name to access the field's dictionary entry.
In the field's dictionary entry, you will find various properties and settings. Look for the "Read Only" property and set it to "true".
you can modify the related UI policy to hide the delete button specifically for the attachment field, further ensuring that users cannot delete attachments.
Edit the UI policy and add a condition targeting the attachment field (e.g., "u_attachment") to hide the delete button. This can be achieved by setting the condition's script to something like:
current.variables.u_attachment.canDelete = false;
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 07:17 AM - edited 07-05-2023 07:17 AM
@Rohit Reddy The control to add/remove attachments are controlled by the UI Page "attachment". Please make the below changes in the UI Page
I have replaced the line"<j:set var="jvar_can_edit_attachments" value="true" />" in line number 96 & 91 this is modified to the below code to check if the table is sc_task and hide the remove button.
<j:if test="${jvar_target_table != 'sc_task'}" >
<j:set var="jvar_can_edit_attachments" value="true" />
</j:if>
After making these changes, I am not able to see the remove option for sc_task
and the same works for incident
Please mark the appropriate response as correct answer and helpful