+ Start a Discussion
Swathi MiryalaSwathi Miryala 

Custom button validate if user exists in Opportunity Team user

I have custom button that calls custom VF page. I need to validate before submitting to VIsualforce page. The condition is if user id is in opportunity team then should redirect to page otherwise should display insufficient rights message.
I have following code
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

sforce.connection.sessionId = "{!$Api.Session_ID}";

var user = sforce.connection.getUserInfo();


if("{!Opportunity.Id}" != "") { 

if("{!OpportunityTeamMember.User.Id}" == user.userId) { 
  window.top.location = "/apex/LibraryRedirect?Id={!Opportunity.Id}"; 
} else { 
  alert("You do not have permissions to upload file"); 
}
 
}

However this - OpportunityTeamMember.User.Id doesnot work.

Can you please help me. 

Thanks,
Swathi
Raj VakatiRaj Vakati
Hi Swathi ,
I think you need to use 
if("{!OpportunityTeamMember.Id}" == user.userId)  not if("{!OpportunityTeamMember.User.Id} 

Thanks ,
Raj