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
Andrew Lewis 9Andrew Lewis 9 

Checking Accounts hierarchy level and passing the parent Id through VF page to report

Hi Everyone,

Brand new to Visualforce and I seem to have hit an error in my syntax, though I believe there is a better way to go about what I am trying to accomplish.

I am attempting to pass an account id to a report and have had success with the below code.
<apex:outputLink onclick="return isClickedInConsole(this)" html-data-reporturl="/{!$Label.Factset_List_View}?pv1={!URLENCODE(LEFT(Account.id,15))}" id="theLink_14">
                <apex:outputLabel value="Factset List View"/>
                <br/>
</apex:outputLink>

But I have now been requested to dynamically send the parent account id if the Hierarchy Level is equal to L3. Using the following code and other similar variations I recieve a syntax error and I am not sure how to go about solving it.
<apex:outputLink onclick="return isClickedInConsole(this)" html-data-reporturl="/{!$Label.Factset_Dashboard}?pv1={!URLENCODE(LEFT({!IF((Account.Hierarchy_Level__C=='L3'),Account.parentid,Account.id)},15))}" id="theLink_13">
                <apex:outputLabel value="Factset Dashboard"/>
                <br/>
</apex:outputLink>

Any help is greatly appreciated, thanks!
Best Answer chosen by Andrew Lewis 9
PavanKPavanK
Hi Andrew,

Thanks for posting.

Could you please try with below code
 
<apex:outputLink onclick="return isClickedInConsole(this)" html-data-reporturl="/{!$Label.Factset_Dashboard}?pv1={!URLENCODE(LEFT(IF(Account.Hierarchy_Level__C=='L3',Account.parentid,Account.id),15))}" id="theLink_13">
                <apex:outputLabel value="Factset Dashboard"/>
                <br/>
</apex:outputLink>
Below line has nested '{!'. this is might be causing issue.

{!URLENCODE(LEFT({!IF((Account.Hierarchy_Level__C=='L3'),Account.parentid,Account.id)},15))}"

Please mark as best answer if my reply helped.

All Answers

PavanKPavanK
Hi Andrew,

Thanks for posting.

Could you please try with below code
 
<apex:outputLink onclick="return isClickedInConsole(this)" html-data-reporturl="/{!$Label.Factset_Dashboard}?pv1={!URLENCODE(LEFT(IF(Account.Hierarchy_Level__C=='L3',Account.parentid,Account.id),15))}" id="theLink_13">
                <apex:outputLabel value="Factset Dashboard"/>
                <br/>
</apex:outputLink>
Below line has nested '{!'. this is might be causing issue.

{!URLENCODE(LEFT({!IF((Account.Hierarchy_Level__C=='L3'),Account.parentid,Account.id)},15))}"

Please mark as best answer if my reply helped.
This was selected as the best answer
Andrew Lewis 9Andrew Lewis 9
It worked! Thanks Pavan! Can't believe I overlooked that.
PavanKPavanK
Not a problem. Thanks for marking.