How to make Attachements Private or Public.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2014 07:23 AM
Hello,
I have a requirement to make attachments to a form as public or private. I have added a checkbox on attachement form named "Is Private file".At the time of attachement if I check the check box, this attachement is private and should be visible to only ITIL and admins. If I dont check this check box by default this attachement will be public and visible to all.
I have tried this on demo019. But I dont find way to proceed to make this functionality work.
Can anyone guide me on that.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2014 01:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2017 03:52 AM
Hi Rohant,
Do you succeeded with your implementation ? We have the same need. Could you give us your solution and the ui page modification that you have done ?
Thanks
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2018 11:00 PM
Hi Rohant,
Please suggest how to add a check box to attachment form
I also have same requirement where I need to add one check box on Attachment form which changes value in a field on Attachment table (created a new check box field to identify which attachment to be restricted ). Please let me know how can I add a check box on Attachment form and how can I pass value from the check box when selected as 'true' to attachment table.
I have written ALC on attachment table based on the true/false value on the new field on attachment table that is working perfectly fine. I only need a way to send true/false value for Private attachments from Incident form.
Please suggest.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2018 07:50 AM
Hi Prrti
I also had the same need and I ended up writing a onLoad client script adding checkboxes to dialog and to files on top of the form, see image and script below (developed in London-version, indentation lost on pasting the script).
I hope this can be of any help, regards
Christian
function onLoad() {
try {
jQuery("#header_add_attachment,#header_attachment_list_label").click(function() {
setTimeout(function() {
addCheckboxes("#attachment_table_body ");
var modalOpen = setInterval(function(){
addCheckboxes("#attachment_table_body ");
}, 1500);
jQuery("#attachment_closemodal").click(function() {
clearInterval(modalOpen);
setTimeout(function() { addCheckboxes(""); }, 0);
});
}, 1000);
});
// On load
addCheckboxes("");
}
catch (e) {
console.log("Error:: Set attachments private");
console.log(e);
}
function addCheckboxes(selectPrefix) {
var attachments = jQuery(selectPrefix + 'a[class*="rename"]');
for (var i = 0; i < attachments.length; i++) {
var attachmentSysId = attachments[i].className.split("_")[1];
var gr = new GlideRecord("sys_attachment");
gr.addQuery("sys_id", attachmentSysId);
gr.query(function(grAttachment) {
if (grAttachment.next()) {
try {
var allreadyAdded = jQuery('#private-checkbox-' + (selectPrefix != "" ? "modal-" : "") + grAttachment.sys_id);
//console.log(allreadyAdded);
var checked = "";
if (grAttachment.u_private == "true") {
checked = "checked";
}
if (!allreadyAdded[0]) {
var renameLink = jQuery(selectPrefix + 'a.attachment.rename_' + grAttachment.sys_id)[0];
renameLink.insert({before:'[<input type="checkbox" id="private-checkbox-' + (selectPrefix != "" ? "modal-" : "") + grAttachment.sys_id + '" ' + checked + ' value="' + grAttachment.sys_id + '">private]'});
jQuery('#private-checkbox-' + (selectPrefix != "" ? "modal-" : "") + grAttachment.sys_id).change(function() {
try {
if (jQuery(this).prop("value").length == 32) {
var grSavePrivateCheckbox = new GlideRecord("sys_attachment");
grSavePrivateCheckbox.addQuery("sys_id", jQuery(this).prop("value"));
grSavePrivateCheckbox.query(); // using synchronous on the save, will not affect page load
if (grSavePrivateCheckbox.next()) {
grSavePrivateCheckbox.u_private = this.checked;
grSavePrivateCheckbox.update();
}
}
}
catch (e) {}
});
}
else {
jQuery('#private-checkbox-' + (selectPrefix != "" ? "modal-" : "") + grAttachment.sys_id).prop("checked", checked == "checked");
}
}
catch (e) {}
}
});
}
}
}