Lightning Forms – Template vs Assignment vs Function Code

Within the expression builder of Lightning Forms, you’ll find 3 different options for creating an expression. In this video, we explore the differences between Template, Assignment and Function Code.

The example Javascript used in Function Code is below:

if ([[FirstName]] !== “” && [[Title]] !== “”)
return [[FirstName]]+” “+[[Title]];
else return null;

An example of using function code for date manipulation can be found below:


 if ([[ContractType]] == “Monthly”) 
  return [[StartDate]].addMonths(1);
 else if ([[ContractType]] == “Quarterly”) 
  return [[StartDate]].addMonths(3);
 else if ([[ContractType]] == “Semi-Annually”) 
  return [[StartDate]].addMonths(6);
 else if ([[ContractType]] == “Annually”) 
  return [[StartDate]].addYears(1);
 else return null;

Related Posts
Clear Filters

Add Comment