- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 12:05 PM
Hi good day!
We have a customized widget in our Service Portal (created by previous developer) that shows that active RITM Tickets (sc_req_item table) and active Incidents (incident table) of user (see image below).
Now, I need to add a new ICON that when click, will show all the active SCTASK (sc_task table) of user.
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 03:09 AM
Hi
Sure will try to assist here. In order to understand what's happening here is as below:
1) When you click on the icon, the list is getting displayed which I believe is a Data Driven OOB widget being utilized here where in the Instance of the widget the Table and conditions are defined to show wither Requested Item or Incident data.
2) So now in order to build a similar functionality please try the steps below and show results what are you getting here:
Press Control on Keyboard and then Right click on the Icon for Incident or Requested Item and then select the option shown in Red below i.e. "Widget in Editor"
Now once you open the widget can you share the result here for all three component below:
HTML
Client Controller
Server Script
So what would be happening here is from this widget they must be passing certain parameter to Data Driven widget and then displaying the result in List format, so need to have a look at the code which you need to share here.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2022 11:37 PM
Hi
Yes it will happen with your current changes which you have made.
I have analyzed further on your code and you need to make couple of changes in order to have this working correctly.
1) First highlighting the Changes which need to be done in order in which I have made and then I will share the final version of the code as well:
a)
var CatQuery = "active=true" + "^ORopened_by=" + gs.getUserID();
var tableCatTask = "sc_task";
b) Added in Line Number 31
var CatCount = getCount(tableCatTask, CatQuery);
c) Added in Line Number 53
var catalog_link = '/id='+url+'New Page Name which you have to give here';
d) Added in Line Number 66
var CATTaskLabel = gs.getMessage("Catalog Task");
e) Added in Line Number 89 and 90
cat = {id: 7, label:CATTaskLabel, icon: 'fa fa-ticket',link:catalog_link,'count':CatCount, page :'New Page Name',visible:data.currentPage=='my_tickets'||data.currentPage=='my_requests'};
categories.push(cat);
Final Server script will look like below:
data.currentPage= $sp.getParameter("id");
//console.log(data.currentPage);
//badge datas
var incQuery = "active=true^caller_id=" + gs.getUserID() + "^ORopened_by=" + gs.getUserID();
var tableInc = "incident";
var CatQuery = "active=true" + "^ORopened_by=" + gs.getUserID();
var tableCatTask = "sc_task";
var watchQuery = "active=true^watch_listLIKE" + gs.getUserID();
var watchTable = "sc_req_item";
var reqQuery = "active=true^request.requested_for=" + gs.getUserID() + "^ORwatch_listLIKE" + gs.getUserID();
var reqTable = "sc_req_item";
var query = "approver=javascript:getMyApprovals()^state=requested^source_table!=change_request";
var table = "sysapproval_approver";
var surveyQuery = "userDYNAMIC90d1921e5f510100a9ad2572f2b477fe^state=wip^ORstate=ready";
var surtable = "asmt_assessment_instance";
var delegateQuery = "userDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORdelegateDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ends>=javascript:gs.beginningOfToday()";
var delegatetable = "sys_user_delegate";
var incCount = getCount(tableInc, incQuery);
var apprCount = getCount(table, query);
var reqCount = getCount(reqTable, reqQuery);
var watchCount = getCount(watchTable, watchQuery);
var surveyCount = getCount(surtable, surveyQuery);
var delegateCount = getCount(delegatetable, delegateQuery);
var CatCount = getCount(tableCatTask, CatQuery);
function getCount(table, query) {
var count= 0;
var rec = new GlideAggregate(table);
rec.addEncodedQuery(query);
rec.addAggregate('COUNT');
rec.query();
if(rec.next()){
count = parseInt(rec.getAggregate('COUNT'));
}
return count;
}
var url= (gs.getProperty('data.url.widget'));
var info_link= '/id=user_profile';
var req_link = '/id='+url+'my_requests';
var incident_link = '/id='+url+'my_incident';
var appr_link = '/id=my_approvals';
var watch_link = '/id='+url+'my_delegates';
var survey_link = '/id=my_surveys';
var catalog_link = '/id='+url+'New Page Name which you have to give here';
//Department items
var categories = [], cat;
//as part of LT
var requestLabel = gs.getMessage("REQUESTS");
var incLabel = gs.getMessage("Incidents");
var apprLabel = gs.getMessage("APPROVALS");
var survLabel = gs.getMessage("SURVEYS");
var profLabel = gs.getMessage("PROFILE");
var deleLabel = gs.getMessage("DELEGATES");
var CATTaskLabel = gs.getMessage("Catalog Task");
cat = {id: 1, label: requestLabel, icon: 'fa fa-shopping-cart',link:req_link,'count':reqCount,page:'my_requests',visible:data.currentPage=='my_tickets'||data.currentPage=='my_requests'||data.currentPage=='my_incidents'};
categories.push(cat);
cat = {id: 2, label:incLabel, icon: 'fa fa-ticket',link:incident_link,'count':incCount,page:'my_incident',visible:data.currentPage=='my_tickets'||data.currentPage=='my_requests'||data.currentPage=='my_incident;
categories.push(cat);
cat = {id: 3, label:CATTaskLabel, icon: 'fa fa-ticket',link:catalog_link,'count':CatCount, page :'New Page Name',visible:data.currentPage=='my_tickets'||data.currentPage=='my_incident'};
categories.push(cat);
if(gs.isLoggedIn() && (gs.getUser().hasRole('business_stakeholder') || gs.getUser().hasRole('approver_user') || gs.getUser().hasRole('itil'))){
cat = {id: 4, label:apprLabel, icon: 'fa fa-check-square-o',link:appr_link,'count':apprCount, page:'my_approvals',visible:data.currentPage=='my_approvals'||data.currentPage=='my_surveys'};
categories.push(cat);
}
cat = {id: 5, label:survLabel, icon: 'fa fa-question',link:survey_link,'count':surveyCount, page :'my_surveys',visible:data.currentPage=='my_approvals'||data.currentPage=='my_surveys'};
categories.push(cat);
cat = {id: 6, label:profLabel, icon: 'fa-info-circle',link:info_link,page:'user_profile',visible:data.currentPage=='user_profile'||data.currentPage=='my_delegates'};
categories.push(cat);
cat = {id: 7, label:deleLabel, icon: 'fa fa-list',link:watch_link,'count':delegateCount, page :'my_delegates',visible:data.currentPage=='user_profile'||data.currentPage=='my_delegates'};
categories.push(cat);
data.categories = categories;
data.myApprovals = getMyApprovals();
//console.log(data.myApprovals);
//console.log(data.categories );
Also couple of more things you need to look at to get this work correctly.
Navigate to Pages module and design a similar page as id ="my_incident" and replace it in the placeholder mentioned in updated script shared above.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2022 08:22 AM
Hi
I also cloned a copy of My Open Incidents (Data Table from Instance Definition) in the sp_instance_table and renamed it as My Open Tasks. How can I add this on my newly cloned "my_sctask" in Pages Module?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2022 12:10 PM
Hi
So I went to sp_instance_table and rename them.
I also changed the Table to sc_task and the fields that will appear on the portal
But I have a couple of problems though
1.) If I click the RITM ICON/INCIDENT ICON and it navigates to its respective URL, it shows all the 3 ICONS (RITM, INCIDENT and TASKS) however, if I click the TASKS ICON and navigate to its URL, it only shows 2 ICONS (INCIDENT and TASKS
2.) I tried impersonating a NON-ITIL user and when I checked the TASKS ICON, there's this error that says: 1 row removed by security constraints. This error only appears on TASK, it is working properly for RITM and INCIDENT.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2022 11:46 PM
Hi
So I went to sp_instance_table and rename them.
I also changed the Table to sc_task and the fields that will appear on the portal
But I have a couple of problems though
1.) If I click the RITM ICON/INCIDENT ICON and it navigates to its respective URL, it shows all the 3 ICONS (RITM, INCIDENT and TASKS) however, if I click the TASKS ICON and navigate to its URL, it only shows 2 ICONS (INCIDENT and TASKS
2.) I tried impersonating a NON-ITIL user and when I checked the TASKS ICON, there's this error that says: 1 row removed by security constraints. This error only appears on TASK, it is working properly for RITM and INCIDENT.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2022 12:32 AM
Hi
Couple of things here again Byron:
1) Can you confirm the changes which I suggested in Server script of the widget has been done?
The changes which you have mentioned above is second part of my suggestion and that looks okay to me but want to check on the first part as well?
2) Screenshots which you have posted is not visible might be it is not uploaded correctly. Can you re upload them again
3) 1 row removed by security constraints - This message has nothing to do with Service Portal configurations or changes you are doing. This comes due to the user with which you are testing does not have appropriate rights to view that Record and is due to some ACL on that table.
4) Can you share some screenshot or more info on your point below:
"If I click the RITM ICON/INCIDENT ICON and it navigates to its respective URL, it shows all the 3 ICONS (RITM, INCIDENT and TASKS) however, if I click the TASKS ICON and navigate to its URL, it only shows 2 ICONS (INCIDENT and TASKS "
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke