суббота, 26 ноября 2016 г.

Flexible Salesforce Site.UrlRewriter implementation

I have recently developed a flexible and useful (I believe) implementation of UrlRewriter for Force.com sites.

Simply define routes as a pattern-target pairs. Each route can be defined from pattern String and target PageReference. Pattern can consist of regular parts as well as of named parameters starting with colon. Parameters would be passed as GET parameters of target Page Reference.

Usage example:
global class SiteUrlRewriter implements Site.UrlRewriter {


    List<Route> routeList = new List<Route> {
        new Route('/account', Page.SiteAccountsList), // --> /SiteAccountsList
        new Route('/account/:accountId', Page.SiteAccountView), // --> /SiteAccountView?accountId=0016C000003eH88
        new Route('/account/:accountId/edit', Page.SiteAccountEdit), // --> /SiteAccountEdit?accountId=0016C000003eH88
        new Route('/account/:accountId/contacts/:regionId', Page.SiteAccountContactsList) // --> /SiteAccountContactsList?accountId=0016C000003eH88&regionId=US
    };    

    // ...

}

In this case the following rewriting will occur:

/account => /SiteAccountsList

/account?directParameter=test => /SiteAccountsList?directParameter=test (direct parameters are preserved as well)

/account/0016C000003eH88 => /SiteAccountView?accountId=0016C000003eH88

/account/0016C000003eH88/edit => /SiteAccountEdit?accountId=0016C000003eH88

/account/0016C000003eH88/contacts/US => /SiteAccountContactsList?accountId=0016C000003eH88&regionId=US

Get code or install in one click from the GitHub repo. Issues and pull requests are welcome!

понедельник, 21 ноября 2016 г.

The easiest way to have iFrames inside your Salesforce Lightning Community

As you know, Salesforce Lightning communities don't support Web Tabs / iFrames natively.

I developed a Lightning Component for Salesforce Communities (see on GitHub) to embed iFrames easily:


It gives administrator an ability to configure iFrames in a few clicks:



There still are some restrictions:

  • Framed page should be HTTPS only due to Salesforce Lightning limitations;
  • Page inside iFrame should support framing (no X-FRAME-OPTIONS DENY or SAMEORIGIN header).
Install in one click from my GitHub here: