Hide Incident and Service Request tasks for end user on portal
Incident Tasks:
Update Status
Resolve
Service Request Tasks:
Cancel Request
Update Status
Complete Request
I have worked with the custom.js file but have been unable to find the right code to hide these tasks for end users.
Any assistance is greatly appreciated.
Thank you
Best Answers
-
Roland_Kind Partner Advanced IT Monkey ✭✭✭
Hi,
this is just an example - but should help
app.custom.formTasks.add('ServiceRequest', null, function (formObj, viewModel) {
formObj.boundReady(function(){
var vm = pageForm.viewModel;
//If the user is not an analyst, hide the task
if (!session.user.Analyst) {
$( ".taskmenu li:contains('Update Status')" ).hide()
}
});
return;
});5 -
Geoff_Ross Cireson Consultant O.G.@Jeff_Landers
Place this code in its own JS file, in your CustomSpace folder (good practice is within another sub-folder to stay organised). Then you need to call that files from within custom.js file. The recommended way is with the scriptloader function. Do you know what that is?
Geoff5 -
Geoff_Ross Cireson Consultant O.G.@Jeff_Landers
This blog which in turn links back to a community post explains it well. But come back here if you have questions.
https://cireson.com/blog/how-to-organize-your-customspace-with-a-script-loader/
'If you were only ever going to use a couple of lines of code to fire off a customization, sticking it directly into the custom.js file in CustomSpace would be enough – job done. But that is rarely the case nowadays as we constantly look for ways to make things better in the Portal. Rather than stuffing multiple bits of custom code into the custom.js file, create a folder for each customization.'
Geoff5 -
Jeff_Landers Customer IT Monkey ✭
I got the tasks hidden for the incident side with this in the custom.js
Is the syntax comparable to hide tasks on the service request side?
I am working on the scriptloader aspect as you recommended.
Thank you for your help
app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
formObj.boundReady(function(){
var vm = pageForm.viewModel;
//If the user is not an analyst, hide the task
if (!session.user.Analyst) {
$( ".taskmenu li:contains('Reactivate Incident')" ).hide()
$( ".taskmenu li:contains('Close Incident')" ).hide()
$( ".taskmenu li:contains('Add Me To WatchList')" ).hide()
}
});
return;
});5 -
Geoff_Ross Cireson Consultant O.G.@Jeff_Landers
Yes, just change 'Incident' to 'ServiceRequest'app.custom.formTasks.add('ServiceRequest', null, function (formObj, viewModel) { ...
Also, you really don't need this linevar vm = pageForm.viewModel;
Its not doing any harm, probably left over from a copy and paste from somewhere, but its doing nothing in the case.
Geoff5
Answers
Hi,
this is just an example - but should help
app.custom.formTasks.add('ServiceRequest', null, function (formObj, viewModel) {
formObj.boundReady(function(){
var vm = pageForm.viewModel;
//If the user is not an analyst, hide the task
if (!session.user.Analyst) {
$( ".taskmenu li:contains('Update Status')" ).hide()
}
});
return;
});
@Roland_Kind, Can you clarify what file this change applies to? Does it work for both SR's and IR's?
Thank you
Jeff
Place this code in its own JS file, in your CustomSpace folder (good practice is within another sub-folder to stay organised). Then you need to call that files from within custom.js file. The recommended way is with the scriptloader function. Do you know what that is?
Geoff
This blog which in turn links back to a community post explains it well. But come back here if you have questions.
https://cireson.com/blog/how-to-organize-your-customspace-with-a-script-loader/
'If you were only ever going to use a couple of lines of code to fire off a customization, sticking it directly into the custom.js file in CustomSpace would be enough – job done. But that is rarely the case nowadays as we constantly look for ways to make things better in the Portal. Rather than stuffing multiple bits of custom code into the custom.js file, create a folder for each customization.'
Geoff
@Geoff_Ross
I got the tasks hidden for the incident side with this in the custom.js
Is the syntax comparable to hide tasks on the service request side?
I am working on the scriptloader aspect as you recommended.
Thank you for your help
app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
formObj.boundReady(function(){
var vm = pageForm.viewModel;
//If the user is not an analyst, hide the task
if (!session.user.Analyst) {
$( ".taskmenu li:contains('Reactivate Incident')" ).hide()
$( ".taskmenu li:contains('Close Incident')" ).hide()
$( ".taskmenu li:contains('Add Me To WatchList')" ).hide()
}
});
return;
});
Yes, just change 'Incident' to 'ServiceRequest'
Also, you really don't need this line
Its not doing any harm, probably left over from a copy and paste from somewhere, but its doing nothing in the case.
Geoff
Is there a way to determine if a user is a member of a certain support group??
//If the user is not in GROUPX, hide the task
if (!session.user.GROUP) { hide the task
Not easily, but haven't you realised yet... There's always a way.
We have to get all the groups a user is in via the API call and then loop through them looking for a group in question. If we don't find it we hide the task.
This is quite expensive so use sparingly. Also I've written it out step by step here, it could no doubt be improved and optimised.
Geoff