cases on service portal needs to open in new tab

tejaswini666
Tera Contributor

Hi,

There is widget to get the list menu of the case table on the service portal and share the code as below,Now the issue  is whenever user opens SOC  "All open cases", they are getting cases list, but when they click cntl+case,its not opening in new tab.so i have tried by using "if (window.event.ctrlKey) {
window.open(url); "in the end of client controller script , it works like only the list menu "All open cases" or "Action needed " opens in new tab whenever i click cntl+Open.But the requirement is whenever user click on "cntrl+case nuber",it needs to be opened in new tab

 

tejaswini666_0-1690533895508.png

 

Client controller script:

function($scope, $location, $timeout, $window, $document, $rootScope, spUtil, spAriaUtil) {
    var c = this;
    spUtil.getPreference('glide.ui.accessibility', function(value) {
        if (value == "true")
            $scope.tabindex = 0;
        else
            $scope.tabindex = -1;
    });
 
    $scope.caseFilterSelected = function(category) {
        var url = "csm?id=csm_my_lists&table=sn_customerservice_soc_case" + "&view=" + category.view + "&target_page_id" + category.targetPageId + "&filter=" + category.query + "&sel=" + category.selectedFilter;
        $location.url(url);
// $window.open(url,"_blank");
if (window.event.ctrlKey) {
   window.open(url);
}
    };
 
}
 
HTML:
<div class="panel panel-{{::options.color}} category-widget no-border">
<div class="panel-heading">
<h2 class="h4 panel-title">
{{::options.title}}</h2>
</div>
<ul class="list-group category-list" role="list" aria-label="${{{::options.title}}}">
<li role="listitem"
class="list-group-item text-overflow-ellipsis"
ng-include="'category-template.html'"
ng-repeat="category in data.list">
</li>
</ul>
</div>
<script type="text/ng-template" id="category-template.html">
<div ng-click="caseFilterSelected(category)"
sn-focus="category.selectedFilter == data.selectedFilter"
ng-class="{true: 'text-active', false: ''}[category.selectedFilter == data.selectedFilter]"
tabindex="0" class="group-item group-item-primary">
<span class="block text-overflow-ellipsis category"
id="{{::category.myListFilter}}"
uib-tooltip="{{::category.myListFilter}}"
tooltip-placement="top"
tooltip-enable="!isTouchDevice()"
tooltip-append-to-body="true">
{{::category.myListFilter}}
<span class="sr-only">${items}</span>
</span>
</div>
</script>
 
Server script:
(function() {
data.list = [];
data.selectedFilter = $sp.getParameter('sel');
data.list = new sn_customerservice.SpotITCSMPortalService().getMyListsMenu("sn_customerservice_soc_case");
})();
6 REPLIES 6

Jean-Yves1
Tera Expert

Hi,

Did you tried to use?
$window.open('https://www.google.com', '_blank');

example:

$scope.caseFilterSelected = function(category, event) {
var url = "csm?id=csm_my_lists&table=sn_customerservice_soc_case" + "&view=" + category.view + "&target_page_id=" + category.targetPageId + "&filter=" + category.query + "&sel=" + category.selectedFilter;

if (event.ctrlKey || event.metaKey) { // Check for Ctrl key (Windows) or Command key (Mac)
$window.open(url, '_blank');
} else {
$location.url(url);
}
};

 

Regards,

tejaswini666
Tera Contributor

Hi Jean,

 

Yes i have tried it, its working as whenever i clicked "all open cases",directly opens in new tab even not clicking CNTL.So thats why i have added if condition.But its not working as expected,working for only list menu options instead of case record

OK, could you try to change like this:

HTML:
.... <div ng-click="caseFilterSelected(category, $event)" .....

 

JS:

$scope.caseFilterSelected = function(category, event) {
var url = "csm?id=csm_my_lists&table=sn_customerservice_soc_case" + "&view=" + category.view + "&target_page_id" + category.targetPageId + "&filter=" + category.query + "&sel=" + category.selectedFilter;
$location.url(url);

if (event.which === 2 || event.ctrlKey || event.metaKey){
window.open(url, "_blank");
}
};

Hi Jean,

 

Still not working, its working same as above.

 

Thanks,

Teja