- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2021 12:07 PM
Change tickets are created from record producer. User attaches a word doc and that carries to the change ticket. User must not be able to edit/remove the attached file on change ticket. This is only on some change requests.
How to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 07:24 AM
This works quite nice to set the internal can_write_to_record (sys_attachment) to false which hides all of the buttons, so the previous 2 changes are no longer needed. Add in the HTML field, line 63 just before this line
<j:if test="${jvar_attachment_disabled == 'true'}" >
<!-- If Firewall Change request, disable adding or removing attachments. -->
<g:evaluate var="jvar_attachment_disabled" jelly="true">
var cr = new GlideRecord(jelly.jvar_target_table);
cr.addQuery('sys_id', jelly.jvar_target_sys_id);
cr.addQuery('short_description', 'CONTAINS', 'Firewall Change');
cr.query();
cr.next();
</g:evaluate>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2021 03:40 PM
Edit is not an issue as no one can really edit an attachment - only add a new one and delete the old one, so you just need to prevent deletion. You can accomplish this with a before Delete Business Rule on the sys_attachment table, something like this
On the When to run tab you'll want to specify to only apply this to attachments to change records
Then the tricky part will be that you only want this on some change requests. If that's a necessary requirement, then try to add whatever criteria determines that to the Filter Conditions, through dot-walking to access fields on the Change record if needed - like Priority, CI, Type, Category,... If you can't get it worked into the Filter Conditions then uncheck both boxes on the Actions tab and write a script to handle the certain change request logic, and add a error message and abort action to prevent the deletion. If you get stuck, let me know the criteria that determines which change requests this attachment deletion restriction should apply to, and I'll try to figure it out with you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2021 01:12 PM
Thank you so much. This is a great help.
Yes I have special criteria, I am going to try that and add my response here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2021 03:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2021 07:28 AM
Yes, I see that's not ideal. New approach. Disable this Business Rule and add a few lines to the Attachment UI Page. This will make the Remove button remain inactive/disabled if the attachment is on a Change Request that has 'Firewall Change' in the Short description. When the box is checked next to an attachment that normally would enable the Remove button, an alert is displayed instead, which is optional.
To do this open the UI Page named attachment. In the HTML field, around line 77 just after the <script> section that is assigning attachmentParentSysId, add these lines to also store the table name.
<!-- Store parent table for use in javascript -->
<script>
var attachmentParentTable = '${jvar_target_table}';
</script>
Next, in the Client script field, add these lines at line 73 just after if(e.checked){ and before removeButton.disabled = "";
if(attachmentParentTable == 'change_request'){
var chg = new GlideRecord(attachmentParentTable);
chg.addQuery('sys_id', attachmentParentSysId);
chg.addQuery('short_description', 'CONTAINS', 'Firewall Change');
chg.query();
if(chg.next()){
removeButton.disabled = "true";
alert('You cannot delete attachments on Firewall Change Request');
}
else{
removeButton.disabled = "";
}
}
else{