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:
EleWise.ELMA.CRM
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
Script:
context.Contact=null;
var settings = (DropDownListSettings)context.GetSettingsFor(c => c.Contact);
settings.Items.Clear();
if(context.Customer!=null)
{
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
});
}
}
settings.Save();