Find your content:

Search form

You are here

How can I link to an app's new record interface from a homepage widget?


I want to create a homepage widget for the sidebar that has a button to create a new record in a custom app (which I intent to distribute, so it needs to be a portable solution).

I'd like to use a button: <button onclick="document.location='/path/to/new/foo'">New Foo</button>

Is there a way to get the path to the app no matter where it's installed? I assume that /a00 in my dev account is just because it's the first app.

Attribution to: RickMeasham

Possible Suggestion/Solution #1

You can add an HTML area component that contains an iframe that loads a VisualForce page with code that generates the URL for the New action of your custom object.

<iframe style="background:transparent; border:0; overflow:hidden" src="/apex/<Name of VisualForce page>" height="100" width="100%"></iframe>

Change <Name of VisualForce page> to the name of the VisualForce page that contains the button:

<apex:page showheader="false" sidebar="false" standardstylesheets="false">
    <apex:form >
        <input type="submit" value="New"
            onclick="'{!URLFOR($Action.<Object API Name>.new)}'; return false;" />

Change <Object API Name> to the API name of your custom object.

Note that iframes don't grow/shrink to fit their content so you'll have to set an explicit height. The loaded content is actually served from the domain, so cross-domain security stops you accessing the parent document to resize it automatically.

Attribution to: E.J. Wilburn
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content