Hide attachment from widget type variable as a checkbox
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 03:26 AM
Hello ,
I have an issue , i have created a checkbox variable through widget , cause i needed to include a hyperlink and on checkbox variable is not feasible.
What i try to do is when the variable is not checked hide the add attachments and when is checked show it.
Any idea on this topic?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:09 AM - edited ‎08-28-2023 04:21 AM
Hello @Ioannis Zapanti,
I am not sure what's your use-case is, but it seems a bit strange. There is much easier way to hide attachment in Service Portal https://www.servicenow.com/community/now-platform-forum/how-to-hide-quot-add-attachments-quot-button....
But if you insist on sticking to your use-case, then one possible way to show or hide attachments based on a checkbox variable in ServiceNow is to use a client script. A client script can run on the client side and manipulate the UI elements based on the variable value. Here is an example of a client script that hides the attachment paperclip if the checkbox variable is not checked:
function onLoad() {
//Type appropriate comment here, and begin script below
var checkbox = g_form.getValue('checkbox_variable'); //get the value of the checkbox variable
if (checkbox == 'false') {
document.getElementById('header_add_attachment').style.display = 'none'; //hide the attachment paperclip
}
}
Hope this helps.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:17 AM
Dear @SwarnadeepNandy ,
Thanks for the answer. Unfortunately i have created the variable as a widget cause checkbox variable doesnt include html to insert hyperlink.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:41 AM
Hello @Ioannis Zapanti,
Not sure what exactly you mean.
Checkbox is a separate variable
HTML type field is a separate variable
You can create URL type variable - https://www.servicenow.com/community/developer-forum/url-variable-type/m-p/1475299
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:47 AM