How to hide attachment on the form ( used form widget OOB) based on the value of a particular field in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 06:51 AM
Hi All,
I have to disable attachments on client script using g_form.disableattachements(). This is working on instance only though i selected UI type as 'All'. This is not working in service portal form widget.
Using atrribute 'no_attachement' it is disabling attachment on all forms on that table.
Unable to disable attachemnts'icon'/'link' on form widget based on the value of particular field.
Please advise.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2019 09:16 AM
You can do that via the CSS part of the widget. Below code should work
sp-attachment-button,
sp-attachment-button ~ span {
display: none;
}
ELSE/Alternate way
1. Navigate to the catalog item in which the "Add attachments" paperclip needs to be hidden
2. Create a new variable of type 'macro' to the specific catalog item
3. Navigate to Service Portal Configuration
4. Create a new Service Portal widget with the following codes in Client controller:
function() {
/* widget controller */
var c = this;
angular.element('label.ng-scope').hide();
//NOTE : The above line here is a JQuery selector inside the angular.element() which is supported in service portal, feel free to change this JQuery selector if you want the attachment element selection to be more specific. In the above code the element label and the class combination are used to hide the attachment
}
5. Add the widget to the Macro type variable created in step 2
Source:https://hi.service-now.com/kb_view.do?sysparm_article=KB0717941
Please hit correct based on impact of response.
Thanks