Activity Forums Salesforce® Discussions How can I link to an app's new record interface from a homepage widget?

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

    Posted by Yogesh on August 9, 2019 at 2:59 pm

    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).

    Laveena replied 4 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Laveena

    Member
    August 19, 2019 at 12:47 pm

    Hi Yogesh,

    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="window.top.location='{!URLFOR($Action.<Object API Name>.new)}'; return false;" />
    </apex:form>
    </apex:page>

    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 force.com domain, so cross-domain security stops you accessing the parent document to resize it automatically.

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos