Lightning Forms – Creating Actions – An Overview of Actions

In this video, we explore the different types of actions that you can create in Lightning Forms. These include Command Bar Button Actions, Form Load Actions, and Button Actions on the Form.

Lightning Forms contains an Action Builder which can be used to define a number of Actions that can take place by clicking a command bar button or a form button, or during form load. Actions such as Save Form, Close Form, Set Field Value, Copy Document, etc are available with Lightning Forms. An additional purchase can be made for Premium Actions such as Document Generator. Below, each of the Actions are described:

  • Condition – The Condition Control enables you to set a condition for when an action or a series of actions can take place. The condition control evaluates to ‘If Yes’ and ‘If No’. Therefore, you can build a condition such as [[Approved]]==’Yes’. If Approved does evaluate to ‘Yes’, actions in the ‘If Yes’ block will run – e.g. email to the claimant that expenses are approved. If the condition evaluates to ‘False’, the ‘If No’ block could send an email notifying the claimant that their expense claim is denied.
  • Loop: apply to each – The Loop: apply to each control allows you to perform an action on multiple list items. An example expression would be: =[[@Actions.Get_items.Items]]. The iterating array would work through all items and allow an action to run against each item in the array.
  • Close Form – The Close form action will close the current form. It is usually a good idea to have ‘Save Form’ preceding a Close Form action unless you are creating the equivalent of a cancel button.
  • Execute Script – The Execute Script Action enables you to write JavaScript code as an action.
  • Redirect to tab – The Redirect to tab enables a tab on the form to receive focus and open. For example, if you have a Approve Button, you could be directed to the Approval Tab on the form.
  • Save Form – The Save Form action will save the current item as a list item.
  • Set field value – Set field value allows you to set a field’s value on the current form – e.g. setting the Approved field to ‘Yes’ when the Approve button is clicked. This should usually be prior to a Save Form action to ensure that your value is saved.
  • Send HTTP Request – Enables GET, POST, PUT, DELETE, JSONP request types to be made. This action can be used to initiate a Power Automate Flow.
  • Open Form – will open a specified form. You will specify the List and the form to open.
  • Open Web Page – Opens any resource by a dynamically generated URL in a browser window/tab or in the current window.
  • Reload – Reloads (refreshes) the current form.
  • Send email – Send email will enable you to dynamically generate an email using fields such as To, CC, BCC, Subject, and Body. The Body can be defined using Rich Text. Attachments, Fallback email, Show before send, and Save to sent items are refinements of the Send email action. NOTE: This action requires the approval of the Microsoft Graph API permission called Mail.Send. For this reason, this action is not available in the SharePoint Server version of modern Lightning Forms.
  • Send internal email is included for backward compatibility with the older Send Email action, which only allowed emails to be sent to people within your organization. Please use the new Send Email action (described above) going forward.
  • Show a message – Shows a notification message to the user completing the form. A message could be a notification such as ‘Expenses Submitted Successfully’. The message can be configured to display for a period in seconds.
  • Add list item – Enables you to dynamically create a list item in another list. This is ideal for tracking history of changes to your form.
  • Copy document – Dynamically copy a document from one library to another in either the current site, another site (named), or another site dynamically set. NOTE: This action is not currently available in the SharePoint Server version of modern Lightning Forms.
  • Create new folder – Creates a new folder dynamically in a specified SharePoint library.
  • Delete item – Deletes an item from a list or library dynamically, based on the item’s ID.
  • Get items – Gets items from a SharePoint list or library so you can use them in, for example, a loop control.
  • Move document – Moves a single document from a source library to a target library/folder. NOTE: This action is not currently available in the SharePoint Server version of modern Lightning Forms.
  • Start Workflow – Starts a new SharePoint 2013 workflow instance
  • Update Item – Can be used to update one or more fields with a calculated expression.
  • Upload Document – Allows you to upload a document to a specified library.
  • Generate Document – Allows you to generate Microsoft Word documents from a SharePoint list item. This is a premium action. Learn how to use the Document Generator.
  • Set variable – Allow you to set a variable value that can be referenced in other actions.

The Actions can be used in both Form Actions and also in Command Button Actions which we will explore below:

Command Bar Actions

In this section, we will create an example Action that Submits an Expense Claim for approval:

  1. Click Actions on the command bar within your desired form.
  2. Choose Command Bar
  • Provide a Display Name such as ‘Submit for Approval’
  • Select an icon (note that you can search for an icon. In the below example, we search on the word ‘Send’)
  • Optionally configure a Visible Expression or Enabled Expression. An example of a useful expression is: [[@User.IsMemberOfGroup(‘Approvers’)]]. This expression will mean that the button is only visible to Approvers.
  • Click Configure Actions.
  • Drag the following Actions in Order:
    • Save Form
    • Send internal email
    • Show a message
    • Close Form

Another example is the scenario is where you use the Get Items action to get items that fit a query and use the Delete Items action to delete the items that have been retrieved.

This is an expansion of the Item Id* expression.

Form Load Actions

As well as building action buttons, Actions can be created against Form Load events. Common Form Load actions include setting values in fields, running a script, or directing the focus to a specific tab. Again, these actions can be conditional.

The form load events include Pre-Form Load and After-Form Load:

  • Pre-Form Load – Actions defined in the pre-form load will fire before the form itself is rendered. This is an ideal time to use the action builder to define variables, or to execute some custom script that is required before the form is rendered.
  • After-Form Load – Actions defined in the After-Form Load run immediately after the form is rendered and the controls on the form are all visible. This is an ideal time to set the focus of the form using Redirect to Tab, or to set values within fields.

Related Posts
Clear Filters

Brett Lonsdale (Co-Founder and CEO of Lightning Tools) and Rob D’Oria (Co-Founder and CTO of Kudzu Software) demonstrate the Kudzu…

In this article we look at how legacy InfoPath Forms can be migrated into Modern SharePoint by using Kudzu Software and Lightning Forms.

Add Comment