- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 11:26 PM
I created the following Client Script to make attachment 'read-only' when "u_state" is NOT "2".
function onLoad() {
var state = g_form.getValue('u_state');
if (state != '2') {
g_form.disableAttachments();
}
}
It works properly for Classic (Platform) UI, but NOT for Service Portal...
Is this method NOT compatible with SP? If so, is there any alternative way to make attachment 'read-only' based on the condition above?
Best Regards,
Aki
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 03:45 AM
@Aki18 TRY THIS
if (current.table_name == "custom_table_name") {
var gr = new GlideRecord('custom_table_name');
gr.addQuery('sys_id', current.table_sys_id);
gr.addEncodedQuery('u_state!=2');
gr.query();
if (gr.next()) {
answer = false;
} else {
answer = true;
}
}
Also try to put some logs in if loop to check if its going inside for loop
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 04:16 AM
The user with itil role can still delete the attachment...
I set gs.info in the if loop and got the system log generated, so I think it's going inside the loop.
Please help me with troubleshooting it.
if (current.table_name == "sn_customerservice_notification_list") {
var gr = new GlideRecord('sn_customerservice_notification_list');
gr.addQuery('sys_id', current.table_sys_id);
gr.addEncodedQuery('u_revision_approval!=2');
gr.query();
if (gr.next()) {
gs.info("test")
answer = false;
} else {
answer = true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 05:25 AM
@Aki18 then i think it should be other acls which might be giving the access check for the acls with read or delete operations where it might be giving the access which might be over riding your ACL
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 01:45 AM
hello @Aki18 ,
if you want to make it read only which means it should be visible but should not be able to delete the attachment then what you can do is write a delete operation ACL on sys_attachment script with the script like below
if(current.table_name=="your_table_name")
{
answer=false;
}
else
{
answer= true;
}
Refer below screenshot :
Hope this helps
Mark my answer as correct if this helps you
Thanks
Mohith