How to Set Widget Visibility... Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2016 12:12 AM
1. I have a requirement to have a particular widget for a special category of the Service Catalogs.
Please can you help me out in setting the visibility of particular widget over "sc_cat_item" page for a special category of the Service Catalogs.
2. Also, I want to hide the Submit Button on the "SC Catalog Item" widget for particular service Catalog.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2022 01:39 AM
Hi
i had used you code ,when i had same requirement but its didn't work can you help with this
this is the code which i had used
HTML :
<div class="col-xs-12 col-sm-6 col-md-4"
ng-class="{'col-md-6' : (c.data.openIncident && c.data.submitCatalog)}"
ng-if="c.data.submitCatalog || data.url_suffix || 'spc' != data.url_suffix">
<button role="button" ng-show="showCategory" class="btn btn-secondary-black" ng-click="kbSubmitRequest()">{{c.options.catalog_button_text}}</button>
</div>
Serverscript :
(function() {
data.showCategory = false;
//to show button for spc catalogs
var showCategory = true;
data.sc_cat_item = $sp.getCatalogItem(data.sys_id);
if (data.sc_cat_item.category) {
var categoryGR = new GlideRecord('sc_category');
categoryGR.get(data.sc_cat_item.category);
data.category = {
name: categoryGR.getDisplayValue('title'),
url: 'spc?id=ays_kb_article&source=search&sys_id=' + categoryGR.sys_id
};
if (data.category.name === "spc catelogs") {
showCategory = true;
}
}
})();
Any helpful thoughts and
Thanks
Mounish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2022 06:59 AM
In your server script, you're going to need to modify the "showCategory = true" line to "data.showCategory = true". Unless you add data to it, this variable only remains accessible in the context of your server script.
Then, step two, add "c.data." to your show/hide condition.
I'm not saying it's the wrong thing to use ng-show, but it's a good thing to keep in mind that there are tradeoffs between ng-if and ng-show, so you'll want to apply whatever makes most sense for your use-case, you can read more about it here: https://www.codelord.net/2015/07/28/angular-performance-ng-show-vs-ng-if/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2022 01:06 AM
Hi
herre is the code of html:
<div class="col-xs-12 col-sm-6 col-md-4"
ng-class="{'col-md-6' : (c.data.openIncident && c.data.submitCatalog)}"
ng-if="c.data.submitCatalog && data.url_suffix && 'spc' == data.url_suffix">
<button role="button" ng-show="c.data.showCategory" class="btn btn-secondary-black" ng-click="kbSubmitRequest()">{{c.options.catalog_button_text}}</button>
</div>
Server script:
data.showCategory = true;
//to show button for spc catalogs
var showCategory = true;
data.sc_cat_item = $sp.getCatalogItem(data.sys_id);
if (data.sc_cat_item.category) {
var categoryGR = new GlideRecord('sc_category');
categoryGR.get(data.sc_cat_item.category);
data.category = {
name: categoryGR.getDisplayValue('title'),
url: '?id=ays_kb_article&source=search&sys_id=' + categoryGR.sys_id
}
if (data.category.name == 'spc catalog') {
data.showCategory = true;
}
}
//to show button for spc catalogs till above
i had given as per the condition but its not working can you let me know any errors
Regards
Mounish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 09:07 AM
Hi Ashish,
Could you please let me know the HTML code which you used to hide the widget?
I am having a similar issue were I am trying to hide a widget if the current user is member of a particular group.
Regards,
Ashwin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2017 01:22 PM
Ashwin,
Did you get a solution for this?