How Can We Help?

Set email address from person field

You are here:

Scenario

You want to set the value of text field to the email address of a user selected in a person field.

Solution

This can be accomplished by adding a simple rule within the Logic screen that grabs the value of the person field, retrieves the email address and sets the text field.

  1. Title: Extract email from Person field
  2. Conditions: None
  3. Steps: Execute custom js function

  Code

// Get the value of the field called HostName
const personFieldValue = getValue("HostName");

if (personFieldValue && personFieldValue.length > 0) {
   // As people pickers store their values in an array we need to extract its first element
   setValue("HostEmail", personFieldValue[0].emailAddress);
}
else {
  // if no person is selected - clear the value
   setValue("HostEmail", "");
}

  Example

 

Once you have configured this it should work like this:

   

Table of Contents

Newsletter sign-up