How to hide attachment icon of catalog item in service portal

sumitjumale
Kilo Contributor

I want to hide attachment icon for specific catalog item in "Service Portal" view.

Note: I am able to hide on normal catalog item view but not in "Service Portal" The code which i have written is working on catalog item view but its not

working on "Service Portal" view even i have used "UI Type = Bothe" in client script.

find_real_file.png

Please suggest.

Regards,

Sumit

21 REPLIES 21

Hi Sumit,



This DOM won't work in Service Portal.



Also are you using scoped app for this?



If yes then have a replica of this script in Global scope and deactivate the current one and test it once.


In global scope you can use dom manipulation in client script.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

I am not using scoped application for catalog item. Client script is in global application only.


Hi Sumit,



It worked for me the same code. Can you check in browser console log.



screenshot below:


attachment-5.jpg



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

The way which you tried is not from service portal. Its normal catalog item view. My script is working in this view but not in service portal view


athm
Tera Guru

Hi Sumit,



I was able to find a solution/work-around if you can add a variable to the specific catalog item you don't want the attachment icon to show up.



1. Create a new variable of type 'macro' to your specific catalog item.


2. Create a new service portal widget, below is the script you need in your Client Controller. You can leave the HTML and Server side scripts as empty/default.



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, for now I am using element label and the class combination to hide the attachment


}



3. Now select the widget created in step 2 as the widget to your variable (shown below).


find_real_file.png



4. Navigate to your catalog item in your portal and now you should not be seeing the attachment icon and related text.



Hope this helps.