- 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 02:21 AM
@Aki18 so you can glide record to that table and add that condition like below
if(current.table_name=="your_table_name")
{
var gr = new GlideRecord('your_table_name');
gr.addQuery('sys_id',current.table_sys_id);
gr.addQuery('u_state','!=','2');
gr.query();
if(gr.next())
{
answer=false;
}
else
{
answer= true;
}
}
This script says if its your table and state is not 2 for that particular record hide the delete button for that record
Hope this helps
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 02:39 AM
Hi @Mohith Devatte ,
I created the delete ACL for itil role as per your instruction, but the user with itil role can still delete the attachment even though the record is "u_state','!=','2'... Any ideas why it's not working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 02:45 AM
@Aki18 can you share the screenshot of the acl and the script also please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 02:59 AM
Please check the followings:
if (current.table_name == "custom_table_name") {
var gr = new GlideRecord('custom_table_name');
gr.addQuery('sys_id', current.table_sys_id);
gr.addQuery('u_state', '!=', '2');
gr.query();
if (gr.next()) {
answer = false;
} else {
answer = true;
}
}
- 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