Post Dreamforce Talk Resources: Rapidly Develop & Deploy Lightning Components with IntelliJ

For those that made it to the Dreamforce 16 talk on Rapidly Develop & Deploy Lightning Components with IntelliJ, a big thank you for coming out. I hope the talk gave you some good ideas on Lightning Component development and encouraged you to checkout IntelliJ & Illuminated Cloud for Salesforce Development. Below are the slides and code for the talk.

Also, you can get the IntelliJ & Illuminated Cloud Shortcuts Cheatsheet HERE.

And the Related Grids Lightning Component for your Org FREE, so you can build Editable Related Lists for any object detail page, declaratively.

The basic Opportunity Related Grid Lightning Component code. MyEditableOptyGrid.cmp:

<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" description="MyEditableGrid2">
    <iframe id="gridFrame" scrolling="auto" height="750" width="100%" frameborder="0"
                    + v.recordId + '&amp;sh=0&amp;ssb=0&amp;sbb=1'}" />

The enhanced, generic component:

<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName"
                description="View Related Grids for an Object. Must use GridWizard to create a grid following the
                naming pattern [Object Name] Related Grid">

    <aura:attribute name="gUrl" type="String" default=""/>

    <aura:handler name="init" value="{!this}" action="{!c.handleInit}"/>

    <iframe id="gridFrame" scrolling="auto" height="750" width="100%" frameborder="0"
            src="{! v.gUrl }" >Loading grid...</iframe>


The front end controller:

    handleInit : function(cmp, event) {

        var action = cmp.get("c.getBaseGridBuddyUrl");
        action.setParams({ objectId : cmp.get("v.recordId"), objectName : cmp.get("v.sObjectName") });

        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                cmp.set("v.gUrl", response.getReturnValue());
            else if (state === "INCOMPLETE") {
                console.log("INCOMPLETE action" + response.getReturnValue());
                alert("Invalid responses from server. Try refreshing the page.");
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " +
                } else {
                    console.log("Unknown error");
                alert("Invalid responses from server. Try refreshing the page.");

The Lightning Design:

<design:component label="Related Grid">

The server side Apex Controller:

public with sharing class RelatedGridsController {

    private static final String GB_SANDBOX = '--gblite.';
    private static final String GB_URL_SUBSTRING = '';
    private static final String HTTPS = 'https://';
    private static final String BASE_HOST = System.Url.getSalesforceBaseUrl().getHost();

    private static String instanceName = null;
    private static Boolean isSandbox = false;
    private static String productionUrl = null;
    private static String sandboxUrl = null;

    public static String getBaseGridBuddyUrl(String objectId, String nameOfObject) {
        String baseGridBuddyUrl = HTTPS;
            baseGridBuddyUrl += sandboxUrl;
            baseGridBuddyUrl += productionUrl;
        baseGridBuddyUrl += EncodingUtil.urlEncode(nameOfObject, 'UTF-8') + '+Related+Grid&id='+ objectId + '&sh=0&ssb=0&sbb=1';
        return baseGridBuddyUrl;

    public static String getSandboxUri() {
        Integer index = BASE_HOST.indexOf('.');
        String part1 = BASE_HOST.substring(0, index);
        String remainder = BASE_HOST.substring(index+1);
        return BASE_HOST.substring(0, index) + GB_SANDBOX +
                remainder.substring(0, remainder.indexOf('.')) + GB_URL_SUBSTRING;

    public static String getProductionUri() {
        Integer index = BASE_HOST.indexOf('my');
        if(index != -1)
            return BASE_HOST.substring(0, index - 1) + GB_SANDBOX + InstanceName + GB_URL_SUBSTRING;
        return '';

    private static void initOrgData() {
        Organization org = [SELECT Id, IsSandbox, InstanceName FROM Organization LIMIT 1];
        isSandbox = org.IsSandbox;
        instanceName = org.InstanceName;
        sandboxUrl = getSandboxUri();
        productionUrl = getProductionUri();

Chris Fellows
posted on 12/14/2017