Auto-fill Email Address Based on User Specified in A Single Line of Text Column in NITRO Forms

Applies to:

SharePoint Online and SharePoint On-Premises

Description

Auto-fill User Information’ settings in NITRO Forms are configured based on logged-in user or based on a user column. In some cases, it is required to store user name in a single line of text column, instead of a user column and configure auto-fill user information settings based on this column. This can be configured using form event actions in NITRO Forms. This article describes steps to auto-populate user’s email address in a text column based on the user that is stored in a single line of text column.

List schema

  1. Custom SharePoint list
  2. The details of the columns used in this example are as follows:
Display NameInternal NameColumn Type
ManagerManagerSingle line of text
Manager EmailManagerEmailSingle line of text

Detailed steps

  1. Configure two single line of text columns and add them on to the NITRO Form:
    1. “Manager”
    1. “ManagerEmail”
      1. This column is to auto-fill email address of the user whose name is entered in the ‘Manager’ column.

2. Configure a Form Event Action in the NITRO Forms.

    Navigate to NITRO Forms designer for the list -> Expand ‘Advanced’ section from the left-hand panel -> Form Event Actions -> ‘New Configuration’ as shown below:

    3. In the ‘Configure Form Event Action’ window, enable ‘Execute on column value change’ -> Select ‘Manager’ column -> Click ‘New Action’ button -> Select ‘Execute Script’ action.

    4. Configure execute script action.

      Specify script in the ‘Configure Execute Script Action’ and save the action.

      Script:

      window.ccs_manager_email = '';
      var webURL = window.ccs_g_FormUI.formSetting.WebURL;
      var managerName = window.ccs_g_FormUI.fetchColumnValueUI("Manager");
      var spContext = window.ccs_g_FormUI.SPUtils.Context;
      if (spContext && managerName) {
        var spUser = spContext.get_web().ensureUser(managerName);
        spContext.load(spUser);
        spContext.executeQueryAsync(
          function(){                     
            window.ccs_manager_email = spUser.get_email();
            functionCallback();
          },function(sender, args){
            console.log("NITRO Forms: User not resolved - " + managerName + ". Error: " + args.get_message());
            functionCallback();
          }
        );
      }
      else
      {
        functionCallback();
      }
      

      5. Configure ‘Update Form Controls’ action and save the settings.

        Click ‘New Action’ button -> Select ‘Update Form Controls’.

        Configure new mapping. Map ‘Manager Email’ column with custom script.

        Script:

        return window.ccs_manager_email;

        6. Publish the NITRO Forms.

          Sample output