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"
            src="{!'https://zencloudtech--qa--gblite.cs2.visual.force.com/apex/Grid?gname=Opportunity+Related+Grid&amp;id='
                    + v.recordId + '&amp;sh=0&amp;ssb=0&amp;sbb=1'}" />
</aura:component>

The enhanced, generic component:

<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName"
                access="global"
                controller="RelatedGridsController"
                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>

</aura:component>

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: " +
                            errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
                alert("Invalid responses from server. Try refreshing the page.");
            }
        });
        $A.enqueueAction(action);
    }
})

The Lightning Design:

<design:component label="Related Grid">
</design:component>

The server side Apex Controller:

public with sharing class RelatedGridsController {

    private static final String GB_SANDBOX = '--gblite.';
    private static final String GB_URL_SUBSTRING = '.visual.force.com/apex/Grid?gname=';
    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;

    @AuraEnabled
    public static String getBaseGridBuddyUrl(String objectId, String nameOfObject) {
        initOrgData();
        String baseGridBuddyUrl = HTTPS;
        if(isSandbox)
            baseGridBuddyUrl += sandboxUrl;
        else
            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


Dreamforce 16 FREE Downloads from Rapidly Develop & Deploy Lightning Components with IntelliJ Talk

Thank you for attending or viewing Rapidly Develop or Deploy Lightning Components in IntelliJ talk at Dreamforce 16!

To help you transition to IntelliJ & Illuminated Cloud, we put together a shortcuts cheatsheet. Download the Shortcut Cheatsheet for free.

For those of you interested in installing Related Grids, the Lightning Component we built at Dreamforce, you can install Related GridsĀ for free as well.

If you have any questions about Related Grids, IntelliJ or Illuminated Cloud, please feel free to comment here on this page or contact us.


Chris Fellows
posted on 12/14/2017