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
Jyoti TrailheadJyoti Trailhead 

Check user location and show tile based on Location on Visualforce page

Hi 

I have an existing VF page which doesn't have any cotroller - it is showing links to others tabs/ pages, I need to show one tile to users only if they are from one particular location - user.location field in User object.

Here is  my code:

<tr  onClick="parent.addTab('BMCRF_HR_ListTickets','Tickets and Requests')">
    <td class="button" width="38em" height="69">
      <div>
      <apex:image style="float:left; margin:1; width:44px; height:45px;"  value="{!URLFOR($Resource.BMCRF_ViewTickets1)}"/>
      <div style="float:inherit">View Tickets</div>
      </div>
    </td>
  </tr>

  <tr  onClick="parent.addTab('BMCRF_HR_KnowledgeArticles','Self Help Articles')">
    <td class="button" width="38em" height="69">
      <div>
      <apex:image style="float:left; margin:1; width:44px; height:45px;"  value="{!URLFOR($Resource.BMCRF_ViewKA1)}"/>
      <div style="float:inherit">View HR and Benefits Knowledge Articles</div> <!--Code Change(Mayur): Label changed from View Knowledge Articles-->
      </div>
    </td>
  </tr>
  
  <tr>
    <td class="button" width="38em" height="69">
      <div>
     <apex:image style="float:left; margin:1; width:44px; height:45px;"  value="{!URLFOR($Resource.BMCRF_ViewKA1)}"/>
      <apex:outputLink target="_blank"  value="https://www.salesforce.com" id="HRChatbot">HR Chatbot</apex:outputLink>
      <!--<div style="float:inherit">HR Chatbot</div> <!--Code Change(Mayur): Label changed from View Knowledge Articles-->
      </div>
    </td>
  </tr>


I need to show the bold HR Chatbot option only to North America users.

Please help.

Regards
 
Best Answer chosen by Jyoti Trailhead
Jyoti TrailheadJyoti Trailhead
I got this done using outputPanel

<apex:outputPanel rendered="{!ISPICKVAL($User.Region__c,'North America')}">
 

All Answers

Saurabh TrailheadSaurabh Trailhead
Wrap the last <tr> table row inside <apex:if> tag, and add a condition when curent user is of North America region.
Jyoti TrailheadJyoti Trailhead
how to check for Current user in VF page itself?
Jyoti TrailheadJyoti Trailhead
I was trying with this - but if condition is not checked and tr is shown for all locations......please help

<tr style="display: {IF(({!$User.Office_Location__c} eq 'Noida,India'), 'none', 'table-row')};">
    <td class="button" width="38em" height="69">
      <div>
     <apex:image style="float:left; margin:1; width:44px; height:45px;"  value="{!URLFOR($Resource.BMCRF_ViewKA1)}"/>
      <apex:outputLink target="_blank"  value="https://www.salesforce.com" id="HRChatbot">HR Chatbot</apex:outputLink>
      <!--<div style="float:inherit">HR Chatbot</div> <!--Code Change(Mayur): Label changed from View Knowledge Articles-->
      </div>
    </td>
  </tr>
Jyoti TrailheadJyoti Trailhead
I got this done using outputPanel

<apex:outputPanel rendered="{!ISPICKVAL($User.Region__c,'North America')}">
 
This was selected as the best answer