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
Jimmy ArmstrongJimmy Armstrong 

$object.ApexPage on Custom button javascript

Hi,

 

I am trying to use the {!$ObjectType.ApexPage} merge field to get the name of a VF page.

This is used on Execute-javascript behavior on a custom button. However I cannot access the

page name that I want to.

 

For e.g.

If the page name is test01 and I try this.

{!$ObjectType.ApexPage.test01}

it throws a syntax  error

 

I can hardcode the VF page name but then I would have to prepend it witht the namespace once I create

a package. This has to be avoided

 

Any help would be great

 

Thanks

-Kedar

Richie DRichie D

Hi,

 

You should be able to use the syntax: {!$Page.test01} to reference your page.

From VF documentation (under global variables)click here

<apex:page>
  <h1>Linked</h1>
  <apex:outputLink value="{!$Page.otherPage}">
    This is a link to another page.
  </apex:outputLink>
</apex:page>

Regards,

 Rich.

 

Jimmy ArmstrongJimmy Armstrong

Thanks for your comment.

 

But the problem is I cannot access $Page on Execute-javascript behavior of a custom button.

Only the $object.ApexPage  global variable is avaialble and it won't

allow me to access the page.

 

 

Richie DRichie D

Sorry, should have read the message properly...

 

Can't offer a solution to this, sorry. In the past (1-2 years ago) there was definitely no solution to this and we ended up prepending the namespace to the button urls. We had 2 buttons for each function; one with, one without the namespace and just added the correct one to the page layout as necessary. It is *really" dirty to do that but that was a solution we came up with at the time.

 

Not sure if there are any better solutions out there these days - lets see what the community comes up with.

 

Good luck.

Rich.