Dynamic Input Field Lightning Component

For a project I am currently working on I wanted to implement a dynamic input field that set it’s body based on the user’s selection of the type of query they are making. There are 6 possible fields the user can query on and these 6 fields can be mapped to 3 types of queries — Date Picker, Date Rage and Input Text. Using what I have learned in dev 601 with Mike Topalovich (kudos again to Mike), I have been actively pairing down and generic-izing (?) every component I build. So this solution needed to be both generic to the given situation and also flexible enough to accommodate the variety of options needed. I ended up creating a simple component to hold the dynamic input field which has optional parameters of “name” and “dynamicSetting”. I wasn’t able to pass the change value to the dynamicSetting on the created component so I have an attribute in the parent that controls the colored label showing the value of the date slider. This is also the value that would be passed to the APEX controller to execute the query.

The main controller passes the value from the onclick event to the helper and runs through a Switch statement mapping the type to the proper input field body. Then the helper sets the body of the dynamic input field accordingly. I declare the dynamicInputField.cmp as a dependency when I load the parent component to avoid trips to the server. I am pretty happy with the result and my only ToDo is minimize the code within the Switch statement to reduce what feels like duplicative javascript. Here are the views of the 3 possible input fields:

Why Lightning is Making Salesforce Even Better For Developers & Admins

I have been developing with the SFDC platform for several years. In this time I have surmounted many a learning curve and devised copious work arounds for dead ends that I have run into because of system limitations. These challenges have been exciting to overcome but have often meant adding code that I knew I would one day be back to refactor. Salesforce has been sold as a clicks not code development platform but as anyone who has implemented SFDC knows there is a limit to where configuration alone can take you. I think this has created divisions between admins and developers. There has not been until now, a way to handoff your beautifully written and toiled over code solutions to your admin wizard friends. Along came Lightning and everything changes…

Adoption is still low because so many users are married to their Classic UI and are not inclined to invest in making the switch or are not sure where to begin. I think that Lightning adoption will grow as more developers understand the power of the framework. I am taking the Dev 601 course this week with Mike Topalovich. Although I have been building some Lightning Components over the past few months, I am finding lots of good nuggets that I have not yet discovered in this training. Kudos to Mike for his depth of knowledge on this subject and for keeping some levity through the tech talk!

Here are some of my favorite learnings so far:

  • Components are your lego blocks… developing with SFDC is now modular by design!
  • <Lightning:layout> component gives you the Grid for free! Crowds go wild… especially those who have toiled over SLDS styling for days….
  • <aura:if> is magical…. I can see use cases with this involving custom component configuration by admins.
  • Expose your components for use by your Admin friends and make them configurable by adding a Design Resource
  • LEX is still a work in progress but there is something special about the SFDC developer community…. (just look at StackOverflow if you don’t believe me) I know that the innovation of folks working with SFDC LEX will grow exponentially now that we have just been given this awesome new set of tools for our toolkit!
  • Javascript, Javascript everywhere…. If you are a JS dork like I am, this is just great news.

….More to come!

 

Summer Camp

Resources for learning online have exploded in number over the past five years. Many of these resources come with a moderate to hefty price tag, eg. Lynda.com or Pluralsight. I will not argue the merit of these subscription learning platforms as I have found their paid content to be valuable —particularly in the case of Lynda as they have free classes but their paid classes include resource files. There are however, many free options that may require a little more setup or self directed research by the user but are akin to the open source version of learning online. Salesforce has Trailhead, a learning platform packed with options and even badges that you can earn to display on your social media profile. The list is long and I don’t only consider the traditional tutorial platforms to be online learning. StackExchange is my personal learning trove. I am usually learning on the go, mid project as I need to understand a tool in a deeper way. StackExchange is perfect for this kind of learning as it is peer to peer but the FCC can’t shut it down because no music companies are being harmed in this trade 🙂

Here is a list for those curious about where to start:

49 of The Best Places to Learn to Code For Free