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
SF7SF7 

Check condition in visual force

Hi 

 

in my VF page i want to render a related list only for one logged in user . can any one provide me the Syntax

 

This is a Standard controller on contact

 

here are the ways i am trying and no success yet

 

<apex:relatedList list="Executive_Notes__r" rendered="{$USER.id = '222222222"}/>

 

and i cretaed a formula filed on contacts to get the logged in person id and check it but even that doesnt work.

 

<apex:relatedList list="Executive_Notes__r" rendered="{!(Contact.Executive_Note__c == '005300000040xoB' )}"/>

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
kevin lamkevin lam

I think you need to use the 18-character user Id, therefore try

 

<apex:relatedList list="Executive_Notes__r" rendered="{!$USER.Id = '00530000004zr4EAAQ'}"/>

All Answers

kevin lamkevin lam

<apex:relatedList list="Executive_Notes__r" rendered="{!$USER.Id = '222222222'}"/>

gautam_singhgautam_singh

Hi,

 

 

Try this , You are missing the $ Symbol. Check this for more details.

 

<apex:relatedList list="Executive_Notes__r" rendered="{!$USER.Id = '1100283848'}"/>



Hope this helps.

Important :

Click on the Star Icon aside if this post provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You

pooja@magichorse.compooja@magichorse.com

<apex:relatedList list="Executive_Notes__r" rendered="{!if($USER.id == '222222222',true,false)}"/>

SF7SF7

Hi Guys ,

 

I tried all three but no luck yet

 

<apex:relatedList list="Executive_Notes__r" rendered="{!$USER.Id ='00530000004zr4E'}"/>
<apex:relatedList list="Executive_Notes__r" rendered="{!if($USER.id == '00530000004zr4E',true,false)}"/>

 

For some reason it is not showing up , the code saves perfectly no errors and even if i remove the condition then related list shows up but the condition is not working.

 

Thanks

Akhil

kevin lamkevin lam

I think you need to use the 18-character user Id, therefore try

 

<apex:relatedList list="Executive_Notes__r" rendered="{!$USER.Id = '00530000004zr4EAAQ'}"/>

This was selected as the best answer
gautam_singhgautam_singh

Hi Akhil ,

 

 

Please try this , This will work surely .. I have tried this in my DEV org and I find that when user ID is 00590000000zssSAAQ then the related list is showing up. Mark it as a solution if this works correctly or let me know if you face trouble in this again.Also , Click the Star Icon to Hit Kudos , If this post os helpful for you.

 

 

Some points to be noted is :-

 

1. It takes 18 digit Id as you are referencing using $ global.

2. Make sure that you have == instead of = .

3. The quote below checks if a user have id = 00590000000zssSAAQ, then it will render the related list else not.

 

 <apex:relatedList list="Opportunities" rendered="!If($USER.Id=='00590000000zssSAAQ',true,false)}"/>

 4. Now the quote below checks the User id , if it is not 00590000000zssSAAQ, then it will render.
     

 <apex:relatedList list="Contacts" rendered="{!If($USER.Id!='00590000000zssSAAQ',true,false)}" >

 

 5.  Read This for More details over Related Lists.



Important :

Click on the Star Icon aside if this post provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You