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
Achilles21Achilles21 

URGENT : IF condition is Visualforce Page

Hi ,

 

I have two different VF Pages say A and B and they are my two different sources for <Apex:iFrame> tab. ( src Attribute )

 

I have one variable <APEX:VARIABLE> and value of which is PRofile ID .

 

Based on Profile , related Iframe should be displayed on VF Page. for example, If its a system admin profile , its should be VF PAGE A and if its a standard User Profile iFrame's src attribute should be VF PAGE B.

 

I have used IF Condition to check the profile but its not working out .

Can anyone help me ?

 

 <apex:iframe src="{!If(p = "00eE0000000hlYJ","/apex/PAGE A","/apex/PAGE B")}" frameborder="0" height="449px" scrolling="no" width="100%"/>
                      

 i m not sure if this is a valid code ! PLEASE HELP ME OUT !! 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You can certainly provide merge syntax in the src attribute of an iframe, and if the code wasn't valid, I'd expect an error when saving.

 

It may be that the ID has been turned into the case insensitive version (which adds three additional characters, giving an 18 character id).  You should be able to find out if that is the case by simply outputting the value of 'p'.  If it is 18 characters, you can use the LEFT function to retrieve the first 15 characters and compare to your fixed value.

All Answers

bob_buzzardbob_buzzard

You can certainly provide merge syntax in the src attribute of an iframe, and if the code wasn't valid, I'd expect an error when saving.

 

It may be that the ID has been turned into the case insensitive version (which adds three additional characters, giving an 18 character id).  You should be able to find out if that is the case by simply outputting the value of 'p'.  If it is 18 characters, you can use the LEFT function to retrieve the first 15 characters and compare to your fixed value.

This was selected as the best answer
Achilles21Achilles21

Thanks a lot Bob. It helped a lot. 

I did exactly as u said .. i outputted value of P .. also, I changed my controller a bit as it was returning DataType PROFILE .. i changed it to String ... and then the comparison worked out properly ... 

 

Again Thanks a ton .. Cheers !!