How can user without admin role can edit the label in attachment upload in workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 01:11 AM
Hi All,
I have requirement where the fulfiller or requester (without admin role) can edit the document label attached to records without changing the extension in workspace. Fulfiller or requester can change the label in native ui but not in workspace.
Can anybody guide me on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 02:07 AM
Hi @SomashekarB,
Can you try following method to acheive the requirement:
Use UI Action to Edit the Attachment Label
- Create a UI Action on the sys_attachment table (or within a custom table) to provide the "Edit Label" option.
- In the UI Action's script, use the same logic as shown in the Script Include above to update the attachment label.
- Assign this UI Action to the workspace form or widget, so users with the appropriate role can see it and modify the label.
Script Include:
var AttachmentUtils = Class.create();
AttachmentUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
updateAttachmentLabel: function() {
var attachmentSysId = this.getParameter('sys_id');
var newLabel = this.getParameter('new_label');
var attachment = new GlideRecord('sys_attachment');
if (attachment.get(attachmentSysId)) {
// Ensure the user has appropriate permissions to modify the attachment
if (this.hasAccess()) {
attachment.setValue('title', newLabel);
attachment.update();
return 'Label updated successfully';
} else {
return 'User does not have permission';
}
}
return 'Attachment not found';
},
hasAccess: function() {
// Ensure user has custom role or necessary permissions
return gs.hasRole('attachment_editor');
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 04:19 AM
I don't want to create UI Action as it will add unnecessary UI action which is not allowed in our requirement. Can we use BR and achieve this?