0

I have a Visual force page which has no dependency of apex class.

I had a formula field called user object label as Business and Api name as Business__c.I need to add condition based on log in user

If login user has two different business sales and Marketing.

My Previous code:

<apex:page sidebar="false">
<apex:iframe src="Link1"
height="1110px" width="1900px" scrolling="true"/>  

</apex:page>

My new code wants to be:

<apex:page sidebar="false">
if(loginuser.Business__c == "sales")
    <apex:iframe src="Link1"
    height="1110px" width="1900px" scrolling="true"/> 
if(loginuser.Business__c == "Marketing")
 <apex:iframe src="Link2"
    height="1110px" width="1900px" scrolling="true"/>   
    </apex:page>

could you please anyone help me how to add condition in vf page without dependency of apex class

1

You can use a CASE statement to dynamically select a link:

<apex:page sidebar="false">
  <apex:iframe src="{!CASE(
     $User.Business__c, 
     'Sales', 'URL1',
     'Marketing', 'URL2',
     null)}" 
     height="1110px" 
     width="1900px" 
     scrolling="true"/> 
</apex:page>
2
  • Thank you so Much sfdcfox , I have another doubt Url1 is using two buisness sales and test
    – user88356
    Dec 17 '20 at 15:18
  • A case statement is already a selection of OR values.
    – sfdcfox
    Dec 17 '20 at 15:44
2

You can use "rendered" attribute of Iframe.

<apex:page sidebar="false">
  <apex:iframe src="Link1"
height="1110px" width="1900px" rendered = "{!$User.Business__c == 'sales'}" scrolling="true"/> 
  <apex:iframe src="Link2" rendered = "{!$User.Business__c == 'Marketing'}"
height="1110px" width="1900px" scrolling="true"/>   
</apex:page>

I have updated your code try this.

1
  • Please don't ask for someone to accept your answer unless they indicate that the answer solved their problem. Read this or more information. You'll get your checkmarks and upvotes simply by providing good answers.
    – sfdcfox
    Dec 17 '20 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy