Hide sent/received email from the activity log (formatter) based on fields, like caller, assigned to

SamuelTse
Tera Guru

Hi,

I was tasked to create something to control who can see the email in the activity log. Our requirement is to only allow the "caller" and "assigned to", maybe "assignment group" to see the email conversation in the activity log. I realize that we can control this by using the UI properties but I can only use specific roles. Is there a way I can control this by ACL? perhaps setting our requirement on the email table's "read" ACL?

I have not tried that yet. any advise will be greatly appreciated.

Thanks,

Sam

1 ACCEPTED SOLUTION

SamuelTse
Tera Guru

I might have found my own solution. All I did was to create an UI policy on Incident with the following configuration:



Conditions:


Assigned to, is not, javascript:gs.user_id(); AND


caller, is not, javascript:gs.user_id();



Script:


function onCondition() {


$j("[name='z*email*']").html(""))


}



This will remove the entire section of the email of each email sent/received. z*email* is the name of the div tag that contains the body of the email. I am okay to leave the header of the email sent in the activity log. I guess I can hide it if I want to, but I prefer to leave it. I assume you can use this method to fitter out or hide cetain information from the email in the activity log, just do a find and replace in html()



By no mean this is the most elegant solution. It's more of a hack from the client side. If anyone sees anythng problem with this approach or better yet, has a better solution, I am all ears



Thanks



Sam


View solution in original post

12 REPLIES 12

venkat2
Kilo Expert

Hi,


I was referring to the client side script. It doesn't matter much whether using an UI policy or a client script eventually its a client side script.


Mateen
Giga Guru

Hello All,



Thanks doe your suggestions. Below script hides emails completely in activity log including headers



var h = document.getElementsByClassName('activity_header');


  var d = document.getElementsByClassName('activity_data');


  if(h){


  for(var i=0;i<h.length;i++){


  if(h[i].innerHTML.indexOf('Email sent')>-1 || h[i].innerHTML.indexOf("Email Received")>-1)


  {


  h[i].style.display="none";


  d[i].style.display="none"


  }



  }


  }


Although this post has been marked as answered, I would like to ask an additional question.


This is the post closest to a solution for my issue that I can find.



Is it possible to exclude the mail from activity list based on either:



The subject of the inbound mail?


or


The inbound action that processed the mail?



Thank you


I guess you can do it. Although I have not tested it, make below changes and it might work



var h = document.getElementsByClassName('activity_header');


  var d = document.getElementsByClassName('activity_data');


  if(h){


  for(var i=0;i<h.length;i++){


  if(h[i].innerHTML.indexOf("Email Received")>-1 &&   h[i].innerHTML.indexOf("subject of your email")>-1)


  {


  h[i].style.display="none";


  d[i].style.display="none"


  }



  }


  }


Hi Abdul,



I can confirm that your code does work.


That is if you make one adaptation. You need to look for the "subject of your email" in the activity data and not in the activity header.



A second difference in my code is that I keep the activity header visible, and   only   hide the actual mail.




Code that I used:



function onCondition() {
var h = document.getElementsByClassName('activity_header');
var d = document.getElementsByClassName('activity_data');
if(h){
for(var i=0;i<h.length;i++){
  if(d[i].innerHTML.indexOf('Subject of your mail')>-1 && h[i].innerHTML.indexOf("Email Received")>-1)
  {


  //h[i].style.display="none";
  d[i].style.display="none"


  }
  }
  }


}