function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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

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

var user = sforce.connection.getUserInfo();

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

if("{!OpportunityTeamMember.User.Id}" == user.userId) { = "/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. 

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

Thanks ,