salesforce data migration services

Learn Salesforce Lightning with Examples – Part 5 (Switch Screens Using Lightning Events)

Learn Salesforce Lightning with Examples – Part 5 (Switch Screens Using Lightning Events) is the fifth part of the series – “Learn Salesforce Lightning with Examples” where We would share the key practical examples and experience with lightning.We are focusing on Lightning Components for now.

Background,Blog Contributors and Pre-Requisites

To get started for this blog you need to fulfill all the Pre-requisites mentioned here.In this link,you will also get to know the background and blog contributors for this series.

Switch Screens Using Events

Business Case:

Adam is working as a Senior Application Developer in Universal Containers. Company wants to move their traditional (classic version )recruitment app to lighting. Adam needs to do a Proof of Concept by building a custom lighting component for creating the Candidate’s record into Salesforce. Now that he has created the first ,second and third part which is explained here,He would like to showcase even users know how to switch screens using lightning events.

Solution:

Before getting started,Adam makes sure that he doesn’t miss any pre-requisites mentioned here.Below are the steps Adam takes for creating the solution after completing the pre-requisites.If you have followed my previous blogs,then you just need to update the components and follow these steps.

The demo prepared first selects the position records and then create candidate records and creates a job candidate record.

Adam decides to go via this approach :

  1. Creates two events,one to change screen and another one to get applied position records.
  2. Events are handled at managecandidate.app
  3. These events are registered at the components to create candidate records and display position records.

Create two events

ChangeScreen Event

[codeblocks name=’ChangeScreen.evt’]

ManageData Event

[codeblocks name=’ManageData.evt’]

Update Application and components code

Application : ManageCandidate.app code

[codeblocks name=’ManageCandidate.app’]

Application Controller : ManageCandidateController code

[codeblocks name=’ManageCandidateController.JS’]

CreateCandidateRecord Component

[codeblocks name=’CreateCandidate.cmp’]

DisplayPositions Component

[codeblocks name=’DisplayPositions.cmp’]

Host and test the application

You need to host the component into the application : managecandidate.app

Now just access the app by using the URL in this format : https://{Domain Name}.lightning.force.com/c/{App Name}.app

You will see a screen similar to this where you can select the positions you want to apply.Once applied,you can click on ‘Go to Candidate’ button :

Once clicked,you will get a ‘new candidate’ page.Once selected,you can hit the continue button,you would get a pop up success message :

and hence a candidate record and a Job Application record will be created:

You can also download the code from the github repository here.

Hope you enjoyed the blog!If you have missed any,then you can go and check here for complete series. Stay tuned and there will be more examples to come ..