0

I need to add some URL parameters in the Send Email button in Email related list in Case detail page.

I have added a custom detail page button with execute javascript. Below is the button code.

     var loc; 
     var uRoleId = UserInfo.getUserRoleId(); 

     if( 
       "{uRoleId}" == "General Permissions Team"){ 
         loc = "/ui/core/email/author/EmailAuthor?p2_lkid=0031500001e729m&rtype=003&p3_lkid=5001500000TkUwp&retURL=%2F5001500000TkUwp&p26=xyz@gmail.com"; 
         } 
     else{ 
        loc = "/ui/core/email/author/EmailAuthor?p2_lkid=0031500001e729m&rtype=003&p3_lkid=5001500000TkUwp&retURL=%2F5001500000TkUwp&p26=test@gmail.com"; 
         } 
         window.top.location.href = loc;

Now when I click on the button , I get a javascript error that user info is not defined. Can you help me point out whats the issue with the button code.

MaxPyne
  • 17
  • 5

1 Answers1

0

UserInfo is not available in JavaScript. Instead you need to use {!$UserRole.Name} to get the role.

Try this:

var loc;
var uRoleName = "{!$UserRole.Name}";

if( uRoleName == "General Permissions Team"){
    loc = "/ui/core/email/author/EmailAuthor?p2_lkid=0031500001e729m&rtype=003&p3_lkid=5001500000TkUwp&retURL=%2F5001500000TkUwp&p26=xyz@gmail.com"; 
} 
else { 
    loc = "/ui/core/email/author/EmailAuthor?p2_lkid=0031500001e729m&rtype=003&p3_lkid=5001500000TkUwp&retURL=%2F5001500000TkUwp&p26=test@gmail.com";
}
window.top.location.href = loc;
Pedro Dal Col
  • 231
  • 1
  • 3