Display the list of customer's contacts

This article describes how to display only the contacts in the drop-down list when selecting a contractor in a process task.

A contractor's contacts can be written to a drop-down list in the script when changing a Contractor variable.
For the script to work, add the following assembly:

Context variables:

context.Contact - drop-down list; the Select from list only box must be checked in its properties
context.Customer - variable of the Contractor type

var settings = (DropDownListSettings)context.GetSettingsFor(c => c.Contact);
  foreach (var item in context.Customer.Contacts.ToList())
    settings.Items.Add(new DropDownItem
      Key = item.Id.ToString(),
      Value = string.Format("{0} {1} {2}", item.Firstname, item.Middlename, item.Surname) //First name, middle name, last name
You can work with contacts in other scripts using the ID, which will be stored in the key property of the resulting list.