Hide "send email" link for AD Groups in Incident
Do i have to use the Custom.js to remove the link, and if so, how?
Thank you in advance !
Best Answer
-
Geoff_Ross Cireson Consultant O.G.Hi Woldgang,
This can be done with a custom task.
app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
formObj.boundReady(function(){
var userid = session.user.Id;
//Call the API to get the User's Groups
$.ajax({
url: "/api/V3/User/GetUsersGroups",
data: {id: userid},
type: "GET",
success: function (groups) {
//Loop through the groups
for ( i = 0 ; i < groups.length ; i++ ) {
//If we find the group in question, hide the task.
if (groups[i].UserName == <Name of AD Group>) {
$( ".taskmenu li:contains('Resolve Incident')" ).hide();
}
}
}
});
});
return;
});
3
Answers
This can be done with a custom task.
app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
formObj.boundReady(function(){
var userid = session.user.Id;
//Call the API to get the User's Groups
$.ajax({
url: "/api/V3/User/GetUsersGroups",
data: {id: userid},
type: "GET",
success: function (groups) {
//Loop through the groups
for ( i = 0 ; i < groups.length ; i++ ) {
//If we find the group in question, hide the task.
if (groups[i].UserName == <Name of AD Group>) {
$( ".taskmenu li:contains('Resolve Incident')" ).hide();
}
}
}
});
});
return;
});
You can inspect the Session.User object in the DOM within your custom.js and trigger the hide based on information within that element. It does not contain a list of AD Groups that the user is a member of however you could feasibly use the API call documented here to retrieve a list of the users groups: https://support.cireson.com/Help/Api/GET-api-V3-User-GetUsersGroups_id
Hi,
thank you for the suggestions. I will look at it and sign up to you.
Yes, we found a solution.
In custom.js you have to add the following lines:
app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
formObj.boundReady(function() {
$("#actionLogisPrivate").trigger("click");
HideSendMailForGroups();
function HideSendMailForGroups(){
var userid = session.user.Id;
//Define the groups which can't see the "send email" link here:
var stsgroups = ["3rdL_AD_Group","2ndL_AD_Group","1stL_AD_Group"];
$.ajax({
url: "/api/V3/User/GetUsersGroups",
data: {id: userid},
type: "GET",
success: function (groups) {
for ( i = 0 ; i < groups.length ; i++ ) {
if (contains(stsgroups,groups[i].UserName)) {
$( ".taskmenu li:contains('Send Email')" ).hide();
}
}
}
});
}